michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

How to set a Light's ColorMode? #257

Closed guytaylor closed 2 years ago

guytaylor commented 2 years ago

I have several different light types and brands and with the following code:

var bowlCommand = new LightCommand();
List<Light> lights = client.GetLightsAsync().Result.ToList();
Light ceiling = lights.FirstOrDefault(c => c.Name == "Study Ceiling Light");  // Gledopto
Light dim1 = lights.FirstOrDefault(c => c.Name == "Left Angle Light"); // Ikea light

bowlCommand.TurnOn().SetColor(new RGBColor(255, 0, 0));               
await client.SendCommandAsync(bowlCommand, new List<string> { ceiling.Id, dim1.Id });

Only the 'ceiling' light changes color, the other 'dim1' just changes brightness. When I peeked into the state of the lights. ceiling.State.ColorMode = "hs" but dim1.State.ColorMode = "ct"

This is the only difference I could see. How do I change the ColorMode of a light? Thanks

michielpost commented 2 years ago

Maybe the Ikea bulb only supports ColorTemprature mode? Try creating a LightCommand and set the ColorTemperatureIncrement property or ColorTemperature int value and see if that has an effect.

guytaylor commented 2 years ago

Thanks. I ended up getting colours working by using 'ColorCoordinates' property and converting RGB to XY That worked on both the Gledopto lights as well as the Ikea ones :)