public void ShowAlert(int lightId, int r, int g, int b, int duration) { // Get current state var light = hueClient.GetLightAsync(lightId.ToString()).GetAwaiter().GetResult(); // Send command to show alert this.SendCommandTo(new LightCommand() { On = true, Alert = duration == 0 ? Alert.Once : Alert.Multiple, }.SetColor(r, g, b), new List <string>() { lightId.ToString() }); // Then restore initial state Task.Factory.StartNew(() => { Thread.Sleep(duration > 0 ? duration > 30000 ? 30000 : duration : 1000); this.SendCommandTo(new LightCommand() { On = light.State.On, ColorCoordinates = light.State.ColorCoordinates, ColorTemperature = light.State.ColorTemperature, Brightness = light.State.Brightness }, new List <string>() { lightId.ToString() }); }); }
public bool GetOn(LightSource ls) { return(_client.GetLightAsync(ls.SystemId).Result.State.On); }