Closed Exergist closed 2 years ago
This code was contributed by @CharlyTheKid in 2016 https://github.com/Q42/Q42.HueApi/issues/70 So not sure, sometimes the documentation is wrong and you can get a 255 value back even it the docs says you don't.
If I set a color via the official Philips Hue app and force the brightness slider to 100%, the reported brightness value is 254.
Based on my testing if I send #FF0000 (pure 'red' at RGB = 255,0,0) to the Hue lights (mine are Gamut C), the color reported back by the lights is #FE0000 (almost pure 'red' at RGB = 254,0,0). I don't think it is possible to convert HSB to RGB and get RGB = 255,0,0 without being able to hit 255 brightness.
After re-reading the API docs I found that brightness is 1-254, and saturation is 0-254. Here's the info (inside the light state object):
I thought I read somewhere that Philips made a conscious decision to make certain values NOT range from 0-255 for rounding simplification. Though that doesn't seem to make a ton of sense considering the above 1-254 and 0-254 ranges exist.
Any additional thoughts @CharlyTheKid?
Within
GetRGB
ofQ42.HueApi.ColorConverters.HSB
is the following:Note that both brightness and saturation are divided by 255. However the Philips Hue documentation states that both these values have maximums of 254. So shouldn't the above calculation divide by 254 instead of 255?
If so, then this logic applies throughout the ColorConverters.