Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong color calucation in HS mode #1128

Closed
sub0ne opened this issue Sep 9, 2019 · 5 comments · Fixed by #1266
Closed

Wrong color calucation in HS mode #1128

sub0ne opened this issue Sep 9, 2019 · 5 comments · Fixed by #1266
Assignees
Milestone

Comments

@sub0ne
Copy link

sub0ne commented Sep 9, 2019

I am using Echo Plus to connect to HA-Bridge directly. When I change the colors the HUE comes in values 0-65535. So the whole RGB calculation failes. This was already discussed in #1060:

Some more color values,l tested in the Alexa app :

Green : {"hue":21845,"sat":254}

Blue : {"hue":43690,"sat":254}

Yellow : {"hue":10923,"sat":254}

Red : {"hue":0,"sat":254}

Magenta : {"hue":54613,"sat":254}

Cyan : {"hue":32768,"sat":254}

Orange : {"hue":7100,"sat":254}

This is what I got from the logs:

hue/sat request - Hue: 21845, Sat: 254, Bri: 0

09-09-2019 22:04:58.147 | DEBUG | hue/sat request - Hue: 21845, Sat: 254, Bri: 0
09-09-2019 22:04:58.183 | DEBUG | calculate HSL vars - var1: 0.0, var_2: 0.0, h2: 0.8333334, h2 + 1/3: 1.1666634, h2 - 1/3: 0.50000334 | com.bwssystems.HABridge.hue.ColorDecode
09-09-2019 22:04:58.184 | DEBUG | hue_2_rgb vh: 1.1666634 | com.bwssystems.HABridge.hue.ColorDecode
09-09-2019 22:04:58.185 | DEBUG | hue_2_rgb vh: 0.8333334 | com.bwssystems.HABridge.hue.ColorDecode
09-09-2019 22:04:58.185 | DEBUG | hue_2_rgb vh: 0.50000334 | com.bwssystems.HABridge.hue.ColorDecode
09-09-2019 22:04:58.186 | DEBUG | Color change with HSL: Hue: 21845, Sat: 254, Bri: 0. Resulting RGB Values: 0 0 0

or

09-10-2019 00:06:52.812 | DEBUG | hue/sat request - Hue: 43690, Sat: 254, Bri: 77
09-10-2019 00:06:52.830 | DEBUG | calculate HSL vars - var1: 0.0, var_2: 0.6039216, h2: 0.16666675, h2 + 1/3: 0.49999675, h2 - 1/3: -0.16666326 | com.bwssystems.HABridge.hue.ColorDecode
09-10-2019 00:06:52.831 | DEBUG | hue_2_rgb vh: 0.49999675 | com.bwssystems.HABridge.hue.ColorDecode
09-10-2019 00:06:52.832 | DEBUG | hue_2_rgb vh: 0.16666675 | com.bwssystems.HABridge.hue.ColorDecode
09-10-2019 00:06:52.832 | DEBUG | hue_2_rgb vh: -0.16666326 | com.bwssystems.HABridge.hue.ColorDecode
09-10-2019 00:06:52.833 | DEBUG | Color change with HSL: Hue: 43690, Sat: 254, Bri: 77. Resulting RGB Values: 154 154 0

since convertHSLtoRGB() calculates wrong RGB values the conversion RGBtoHSB() also produces wrong values.

@sub0ne
Copy link
Author

sub0ne commented Sep 11, 2019

@bwssytems:
any feedback on this yet? This is imho a serious bug as it's impossible to change colors of a Philips hue bulb.

@bwssytems
Copy link
Owner

I'll look into it

@sub0ne
Copy link
Author

sub0ne commented Sep 11, 2019

ok, thank you. What I did was changing color via Echo Plus Alexa and via Alexa app. What I'm going to try is checking out how the Philips App behaves.

From what I got from the internet it seems hue (on Philips Hue) is a value between 0 - 65535. Division by 182.04 results in 'regular' hue values. As you can see the value is send from the Alexa to the HA-Bridge.

I'm using a ioBroker and (Simple API, deCONZ adapter) with deCONZ, last one requires Hue

@bwssytems
Copy link
Owner

Will be writing a test case for this and will validate the calculation

@bwssytems bwssytems self-assigned this Sep 24, 2019
@bwssytems
Copy link
Owner

Having a very hard time with this conversion as Philips does not publish their calculation.

@bwssytems bwssytems added the bug label Oct 2, 2019
@bwssytems bwssytems added this to the 5.3.1 milestone Oct 2, 2019
bwssytems added a commit that referenced this issue Dec 14, 2020
Dev branch 5.3.x to create v5.4.0

#1044 Alexa app, error "Device doesn't support requested value" bug question
#1118 Device status update in Alexa App is not working correctly for ha-bridge devices bug duplicate question
#1126 Can't get XY ColorData into URL enhancement question
#1127 Can't get separate hue, saturation and brightness enhancement question
#1128 Wrong color calucation in HS mode bug question
#1131 Changing color temperatur is not working correctly bug question
#1132 Conversion from CIE to RGB incorrect bug question
#1139 Device ID creation fails bug question
#1150 Home Assistant gets null exception during initialization bug question
#1170 Alexa not sending the correct color codes duplicate
#1171 Please add option: If bright request present with on, only send dim enhancement
#1184 Alexa will not discover HABridge question
#1191 When "Use UPNP Address Interface Only" is selected, echo cannot find ha-bridge bug
#1210 [Enahnacement] Have link button timeout be configurable enhancement
#1215 Alexa unable to discover recently added devices to ha-bridge duplicate question
#1227 Feature request: ${intensity.previous} value passing control enhancement
#1239 HA-Bridge has suddenly given up itself - Exception in thread "main" java.lang.NullPointerException bug question
#1243 Alexa device discovery now broke question
#1253 HABridge hue ColorDecode 0 0 0 bug question
#1256 Homeassistant devices not appearing bug question
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants