michielpost / Q42.HueApi

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

GetRGB not exposed #242

Closed albusmw closed 3 years ago

albusmw commented 3 years ago

Hi! I am using your code as build 3.16.0.0 and see no chance to set the color to a certain RGB value. There is code inside but it is internal, I can only use the 2 value ColorCoordinates. May it be possible to expose a conversion function? I am on VS2019 community with VB.NET and .NET Framework 4.7.2. Best regards Martin.

michielpost commented 3 years ago

You will need to include the Q42.HueApi.ColorConverters nuget package. After that, you can use one of the three included color converters.

For example, the original one has this extension method: https://github.com/Q42/Q42.HueApi/blob/a28d642ac50e5e8027e9b211b72a2e385c1c8534/src/Q42.HueApi.ColorConverters/Original/Extensions/LightExtensions.cs#L16

So if you have a Light object, you can call light.ToRGBColor() to get the RGB value.

michielpost commented 3 years ago

Or create a light command and set the color of the light to a RGB value with this SetColor extension on LightCommand: https://github.com/Q42/Q42.HueApi/blob/a28d642ac50e5e8027e9b211b72a2e385c1c8534/src/Q42.HueApi.ColorConverters/Original/Extensions/LightCommandExtensions.cs#L12

albusmw commented 3 years ago

OK, thanks, I was not aware that I need another package. I now do Command = Q42.HueApi.ColorConverters.Original.LightCommandExtensions.SetColor(Command, New Q42.HueApi.ColorConverters.RGBColor(LEDColor.R, LEDColor.G, LEDColor.B), "LCT001") and that works ... Regards Martin.