[hue] Improvements for exotic light models#21062
Conversation
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>
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>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
- harmonize contract between handler and resource - log stack trace if critical field is missing - fix brightness and on/off handling - fix test cases for brightness and on/off and missing critical field - apply full dto's for min dim level, mirek schema, gamut - change color transforms to use actual gamut if available 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>
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>
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>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
|
Thanks for all these fixes and improvements! I'll try to have a look as soon as possible, and also get it into my production system for some testing. One that I'm curious about:
I actually never experienced that with any of my Trådfri bulbs (which I have a variety of). Are Trådfri bulbs still being sold? I thought IKEA switched to Thread entirely. Perhaps this is a firmware bug in newer bulbs? I assume this means you are not able to turn off such a bulb from the Hue app either? In the specific case of LK Wiser (LK is Lauritz-Knudsen, a Danish part of Schneider Electric), apparently the Zigbee incompatibility stems from a Tuya implementation adopted by the subcontractor that did at least the initial Zigbee implementation for them. |
To be frank, I don't know; I got it on eBay so I have no clue about its age.
Nope. It works just fine in the App. (But the App dimmer slider only goes from 100% to 1% ..)
Interesting. I think the Hue Bridge does accept Tuya lamps? If so I might buy one (on eBay) to test. PS elsewhere you mentioned a Light Solutions Dimmer-Switch-ZB3.0 which may perhaps also have the same issue (??) |
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
I think it might be a different issue then. The issue with the LK Wiser dimmer is pretty clear, and it doesn't turn off from the app either. The details are in my blog post LK Fuga Wiser Wireless Dimmer hands-on. The app doesn't send
I don't know how widespread the problem is, but I seem to remember on some forum that other users linked this to be a Tuya issue. So you might get "lucky" if you find some other cheap Tuya bulb or similar. The Light Solutions Dimmer Switch seems to be "playing by the rules" and fully Zigbee compliant. I have no issues turning it off. I only ever experienced this with Wiser products. |
| */ | ||
| private static final Set<String> WORK_AROUND_MODEL_IDS = Set.of( // | ||
| "LK Dimmer".toLowerCase(), // LK Wiser Dimmer -- see https://techblog.vindvejr.dk/?p=455 | ||
| "Tradfri".toLowerCase() // IKEA Tradfri bulbs |
There was a problem hiding this comment.
Since it's not a general issue with TRÅDFRI, we might need to tweak something here. The work-around is to use dynamicsDuration which is Duration.ZERO as default. This will override the transition time for all TRÅDFRI bulbs from the 400 ms Hue default transition time (when not provided). See also #15323.
We can come back to this after #21062 (comment), which is still a bit confusing for me.
There was a problem hiding this comment.
So my bulb with the bug is Model Id "TRADFRI bulb E27 WS globe 1055l" => perhaps you can give me the respective Ids of your bulbs that do not have the bug. Maybe there is some way to differentiate deeper?
HOWEVER, I also have Tradfri lights in my kitchen and in a display cabinet. And indeed those ones do not suffer from the bug e.g. below..
Well it might indeed be a different issue, but the solution is exactly the same -- namely (as you say) -- adding a dynamics duration to the command JSON payload (it actually doesn't matter whether the dynamics duration is 0 or something else; it just has to be present in the payload). |
This PR resolves many issues with "exotic" light models. In this context "exotic" mostly means lights made by third parties other than Philips / Signify ("Friends of Hue") which are therefore not certified for full compliance with the Hue API v2. Albeit it covers a special case with the Philips / Signify "Signe" model as well.
For testing purposes the JARs are here:
Specifically this PR does the following:
Some non certified lights fail to provide a minimum dimming level - see [hue] IKEA Trådfri bulb turns off when setting low brightness #21057 and currently in that case the binding substitutes a default value of 0.5. This was apparently too high for some. So this PR reduces that to 0.39 (aka 100/255) instead.
Some certified lights do provide a minimum dimming level of 0.0 (e.g. Philips Signe) and currently therefore sending 0.0 to the bulb fails to turn it off. So this PR overrides the 0.0 to 0.01 in order to ensure that a precise 0.0 command will turn the lamp off.
Some non certified lights fail to provide minimum and maximum supported Mirek values. So analogous to the case with dimming level above, this PR defaults to the min .. max range of 153Mk .. 500Mk.
Previously the binding did not use the Gamut provided by certified lights. It always used the default Gamut instead. As a general rule Philips / Signify lights do provide a Gamut, whereas non certified products generally do not. With this PR now we use the Gamut if provided, and only use the default if none is provided.
Some non certified lights provide invalid minimum and maximum supported Mirek values. So this PR checks those values and if necessary defaults to the min .. max range of 153Mk .. 500Mk.
The increase/decrease button support has been improved by adding support for the
dimming_deltaandcolor_temperature_deltafields in the Resource DTO, and havingIncreaseDecreaseTypecommands use those fields.As a consequence of the above changes, the thing handler calls a new extra added method that ensures the light state cache contains all the required parameters for minimum dimming level, mirek schema, and gamut -- be they provided by the device itself in its initial GET response, or otherwise using the system defaults.
Often non certified lights will respond to a PUT request with an HTTP 207 error rather than HTTP 200. In the past, when the bridge returned an HTTP 207 response "soft off" the binding would produce an
INFOlog output. This PR reduces that toDEBUGlevel.On some non certified lights, when the bridge returned an HTTP 207 response, the devices would not send an SSE event update with the new state. This PR adds a loopback whereby the JSON of the PUT request that caused the 207 response is looped back to the binding as a dummy event. This prevents the states in the UI from "flapping".
In the prior version of the binding code I had wrongly assumed that the min .. max range of the dimming channels were "minimum dimming level .. 100%). This PR refactors the code so the min .. max range of the dimming channels are now "0% .. 100%" regardless of the actual minimum dimming level.
As a consequence of my misunderstanding about the min .. max range of the dimming channels, the binding was incorrectly calculating the threshold to be used when determining the changeover point between sending a hard on or a hard off command. This applied in particular to non certified products that do not provide their own minimum dimming level. This PR adds an extra
Settersmethod that fixes the threshold and implements the hard on/off logic.The prior version of the binding code would wrongly produce Channel State values of
UNDEFin some cases when certain DTO fields were missing. Again in particular it occurred for non certified products. In this PR someUNDEFcases are eliminated, and instead an exception may be thrown at runtime (see next point)... therefore, in this PR now when a device delivers a DTO with incomplete data, rather than producing the opaque
UNDEFstate, the binding now logs the detailed error toDEBUGwith a full stack trace instead. The extra transparency should help fixing future non certified light models.In order to test the above changes I purchased both a Lidl Livarno TS0502A E27 CT bulb that should be similar to the TS0505A of @kaikreuzer and also an Ikea Tradfri 1055 lumen E27 bulb that should be similar to the Tradfri lamp of @jlaur, for testing the code. And as far as I can tell the errors reported in the below mentioned issues have now been resolved.
It seems that the (also non certified) "Ikea Tradfri" bulbs suffer the same bug as the "LK Wiser Dimmer". So this PR extends the same fix to those Tradfri bulbs.
Furthermore, if a room or zone contains such a Tradfri or LK Wiser light, then the bug also occurs on the respective room or zone. So this PR applies the same fix to such things. It also applies the fix to the "all lights zone".
The Junit tests have been adapted to the above.
NOTE: in one of the issues below @kaikreuzer had mentioned that his light would revert to another color temperature state after some variable time between 12 and 45 seconds. My hypothesis is that you had the Hue App open on that light, since the Hue App is known to send refreshes of the state that it is displaying in its own UI from time to time. (I noticed this myself when testing..)
Resolves #21057
Resolves #21044
Resolves #21045
Resolves #21043
Resolves #21011
Signed-off-by: Andrew Fiddian-Green software@whitebear.ch