setColor() works better with Hue Sat than RGB
Opened this issue · 1 comments
Hello,
Not an issue, but a feedback.
I need to set the exact color of the device in my sketch.
Usual color code is RGB, so I tried this :
EspalexaDevice* d = espalexa.getDevice(0);
d->setColor(255,0,0); //red
d->setColor(0,255,0); //green
d->setColor(0,0,255); //blue
None of these worked as expected. The App did not recognize the color set and showed "personalized color" with no color selected.
After strugling a while, I found it is probably due to the conversion from RGB to XY in the library (rounding issue ?).
If it was a real lamp, nobody would notice the color difference, but I need a perfect match in my code.
Switching to (Hue,Sat) worked perfectly: colors are recognized by the Alexa app.
d->setColor(0,254); //red
d->setColor(21845,254); //green
d->setColor(43690,254); //blue
The next question is how to find the correct (Hue, Sat) converted codes from RGB ?
The converters I could find did not help.
The easiest for me was to use the piece of code provided in the EspalexaFullyFeatured.ino example which uses getColorMode().
Just ask Alexa to change to the color you want or tap in the app.
conversion table for the Philips Hue colors available in the Alexa app, listed in csv.
Whites are best set in CT colorMode. Colors are best set in Hue,Sat ColorMode.
WHITE
-------
Name, uint32_t, Hex, RGB, colorMode, Value
warm white, 16753231, FFA24F, (255, 162, 79), CT, (383)
soft white, 16755295, FFAA5F, (255, 170, 95), CT, (350)
white, 16760972, FFC08C, (255, 192, 140), CT, (284)
daylight white, 16765615, FFD2AF, (255, 210, 175), CT, (243)
cold white, 16770253, FFE4CD, (255, 228, 205), CT, (199)
COLOR
-------
Name, uint32_t, Hex, RGB, colorMode, Value
red, 16711680, FF0000, (255, 0, 0), HS, (0, 254)
crimson, 16717638, FF1746, (255, 23, 70), HS, (63351, 231)
salmon, 16752762, FFA07A, (255, 160, 122), HS, (3095, 132)
orange, 16754176, FFA600, (255, 166, 0), HS, (7100, 254)
gold, 16765952, FFD400, (255, 212, 0), HS, (9102, 254)
yellow, 16711424, FEFF00, (254, 255, 0), HS, (10923, 254)
green, 65280, 00FF00, (0, 255, 0), HS, (21845, 254)
turquoise, 4718572, 47FFEC, (71, 255, 236), HS, (31675, 183)
cyan, 65279, 00FEFF, (0, 254, 255), HS, (32768, 254)
sky blue, 9691391, 93E0FF, (147, 224, 255), HS, (35862, 107)
blue, 255, 0000FF, (0, 0, 255), HS, (43690, 254)
purple, 11215871, AB23FF, (171, 35, 255), HS, (50426, 219)
magenta, 16711934, FF00FE, (255, 0, 254), HS, (54613, 254)
pink, 16760779, FFBFCB, (255, 191, 203), HS, (63351, 64)
lavender, 10452991, 9F7FFF, (159, 127, 255), HS, (46421, 127)