Пример #1
0
        public async void StoreDevicesToFile()
        {
            var ewelink = new Ewelink(Email, Password, Region);
            await ewelink.GetCredentials();

            await ewelink.GetDevices();

            ewelink.StoreDevicesToFile();
        }
Пример #2
0
        public async Task GetDevices()
        {
            var ewelink = new Ewelink(Email, Password, Region);
            await ewelink.GetCredentials();

            await ewelink.GetDevices();

            output.WriteLine(ewelink.Devices.AsJson());
        }
Пример #3
0
        public async void Open()
        {
            var ewelink = new Ewelink(Email, Password, Region);
            await ewelink.GetCredentials();

            await ewelink.GetDevices();

            ewelink.OpenWebSocket();
            ewelink.CloseWebSocket();
        }
Пример #4
0
        public async void GetDeviceByDeviceName()
        {
            var ewelink     = new Ewelink(Email, Password, Region);
            var credentials = await ewelink.GetCredentials();

            await ewelink.GetDevices();

            var device = ewelink.Devices.First(x => x.name.Contains(deviceName, StringComparison.OrdinalIgnoreCase)) as SwitchDevice;

            output.WriteLine(device.AsJson());
        }
Пример #5
0
        public async void GetDeviceByDeviceId()
        {
            var ewelink     = new Ewelink(Email, Password, Region);
            var credentials = await ewelink.GetCredentials();

            await ewelink.GetDevices();

            var device = ewelink.Devices.First(x => x.deviceid == deviceId) as SwitchDevice;

            output.WriteLine(device.AsJson());
        }
Пример #6
0
        public async void SetPulse()
        {
            var ewelink     = new Ewelink(Email, Password, Region);
            var credentials = await ewelink.GetCredentials();

            await ewelink.GetDevices();

            var device = ewelink.Devices.First(x => x.deviceid == deviceId) as SwitchDevice;

            device.SetPulse("on", 5000);
        }
Пример #7
0
        public async void TurnOffDevice()
        {
            var ewelink     = new Ewelink(Email, Password, Region);
            var credentials = await ewelink.GetCredentials();

            await ewelink.GetDevices();

            var device = ewelink.Devices.First(x => x.deviceid == deviceId) as SwitchDevice;

            device.TurnOff();
        }
Пример #8
0
        public async void GetChannel()
        {
            var ewelink     = new Ewelink(Email, Password, Region);
            var credentials = await ewelink.GetCredentials();

            await ewelink.GetDevices();

            var device = ewelink.Devices.First(x => x.deviceid == deviceId) as MultiSwitchDevice;
            var state  = device.GetState(0);

            output.WriteLine(state);
        }
Пример #9
0
        public async void Listen()
        {
            var ewelink = new Ewelink(Email, Password, Region);
            await ewelink.GetCredentials();

            await ewelink.GetDevices();

            var messages = "";

            ewelink.webSocket.OnMessage += (s, e) => messages += e.Message.AsJson();
            ewelink.OpenWebSocket();

            System.Threading.Thread.Sleep(2000);

            output.WriteLine(messages);
        }