Skip to content

Wrong color calucation in HS mode #1128

@sub0ne

Description

@sub0ne

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions