public async void StoreDevicesToFile() { var ewelink = new Ewelink(Email, Password, Region); await ewelink.GetCredentials(); await ewelink.GetDevices(); ewelink.StoreDevicesToFile(); }
public async Task GetDevices() { var ewelink = new Ewelink(Email, Password, Region); await ewelink.GetCredentials(); await ewelink.GetDevices(); output.WriteLine(ewelink.Devices.AsJson()); }
public async void Open() { var ewelink = new Ewelink(Email, Password, Region); await ewelink.GetCredentials(); await ewelink.GetDevices(); ewelink.OpenWebSocket(); ewelink.CloseWebSocket(); }
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()); }
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()); }
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); }
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(); }
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); }
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); }