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
[hue] Improve color setting #16436
[hue] Improve color setting #16436
Conversation
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
...binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/helper/Setters.java
Outdated
Show resolved
Hide resolved
See also openhab/openhab-core#4124 |
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/hue-bulb-changing-color-wrongly-when-brightness-is-0/154005/18 |
Changed to WIP pending #16482 |
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/hue-bulb-changing-color-wrongly-when-brightness-is-0/154005/26 |
EDIT: I am wondering if the xy should be constructed from an HSB with a fixed B? reason is that the dimmer data is anyway separately transmitted on a different DTO.. EDIT 2: to answer my own question: it should not use a fixed B. Reason is that the Gamma Correction needs to be applied. However I think there may be another bug in the Hue binding whereby reverse gamma correction is being omitted. I will check it.. EDIT 3: it’s 4:30 AM and I had an epiphany. Marking this now as WIP again.. |
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Ok. I have now also fixed the gamma round trip issue. Ready to go again. :) |
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/hue-bulb-changing-color-wrongly-when-brightness-is-0/154005/31 |
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor comment from my side to remove "TODO" code smells.
Is it correct that this PR no longer has any direct relation to openhab/openhab-core#4124 (besides the tests that might be affected), but completely independently fixes issues in the binding that would have to be fixed the same way with or without openhab/openhab-core#4124?
@kaikreuzer - would you like to complete your review after the latest changes and simplifications?
....binding.hue/src/test/java/org/openhab/binding/hue/internal/handler/HueLightHandlerTest.java
Outdated
Show resolved
Hide resolved
....binding.hue/src/test/java/org/openhab/binding/hue/internal/handler/HueLightHandlerTest.java
Outdated
Show resolved
Hide resolved
Correct.
|
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@kaikreuzer I believe that @jlaur is deferring until you complete your own review of this. So in order to make progress, I wonder if there is any further information that you need from my side, in order to help that? |
@jlaur All fine for me; so feel free to merge if you are fine with it as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* [hue] fix xy conversion when B is 0 * [hue] remove gamut correction; let Hue bridge do it instead * [hue] fix gamma round trips; modernize instanceof syntax Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [hue] fix xy conversion when B is 0 * [hue] remove gamut correction; let Hue bridge do it instead * [hue] fix gamma round trips; modernize instanceof syntax Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch> Signed-off-by: Alexander Drent <Alex@Drent-ict.nl>
There are three issues..
1) Hue bulb changing color wrongly when brightness is 0
As reported on the forum here if OH sends an HSBType color command, where B is 0, it causes the wrong color value to be set on the lamp.
The reason is that the
ColorUtil.hsbToXy()
method produces, for the special case where B is 0, an xy color co-ordinate of [0,0] which is outside the color gamut of any physical lamp; and this (wrongly) causes the gamut correction to convert that [0,0] value to the closest xy color co-ordinate within the actual lamp's color gamut i.e. namely it sets the lamp to itsgamut:blue
color.2) Use same color Gamut as Hue App
See this #16482
3) RGB gamma correction is inconsistently applied
See core #4102
When the binding sends a color XY command to the bridge, it applies a variable gamma correction depending on the dimming level of the lamp. Whereas when the bridge sends an XY state update to the binding, it applies a fixed reverse gamma correction that does not depend on the dimming level. This means that the round trip HSB => xy => bridge => xy => HSB has inconsistent results particularly at low brightness levels.
This PR fixes all these issues (resolves #16482). (Plus some modernizations of
instanceof
syntax).The Jar file in Zip form is here
Signed-off-by: Andrew Fiddian-Green software@whitebear.ch