-
Notifications
You must be signed in to change notification settings - Fork 501
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
Fix for issue 1861 #2507
Fix for issue 1861 #2507
Conversation
Thanks for the PR, does the ct mode then still work for the IKEA CWS color light? |
I don't know, I don't have these lights. This change I have done is a change of @Flurkmark. He is using this change for a while now without issues. |
I do have these lights, and I had introduced that code you're commenting it out. Commenting it out breaks the I'm not quite sure if I understand what is the original issue, maybe I can recommend an alternative fix and help testing it (I have both WS and CWS lights). |
Initially a CT light bulb is correctly processed as a CT bulb, but when changing the color temperature using the REST API (what happens when you use Home Assistant), Deconz reports the same light bulb as a XY bulb. |
Thank you. I also use Home Assistant. I will try to replicate and get back, and hopefully propose some alternative. |
Any success in replicating the issue? |
Hi, sorry for the delay. With the coronavirus and some other personal stuff going on, I couldn't take a look at it. But now I have. I could replicate your video: When I turn on the light on with the physical switch, I do see the The reason for why this happens is because IKEA lights have a firmware bug in which they don't remember the color temperature in scenes, unless the colour is set via On top of that, I introduced [4] to use the same mechanism to allow using Commenting out the line you proposed in this PR would cancel the first behaviour I mentioned above, which would be a pretty annoying regression: when saving scenes, IKEA lights won't remember their light colour (unless they recently fixed this bug, but I saw no evidence of that). Now, I totally understand this is frustrating and causes this side effect. I think this could be fixed by making deCONZ pretend it sent the original I'll need to dig into the source code again and check what's feasible. @manup, @ebaauw: any other suggestions? |
I'm afraid, you don't want to ask me in this case; I'm no fan of this functionality. See my post on the API v2 (#1688) about a "raw" vs a "cooked" API:
I think the current API is more "raw" than "cooked", and should stick to exposing the lights as they are, warts and all. Imho, introducing "cooked" features like mapping |
I have read it back then and I actually agree with you. However, the current situation is what it is, and the 2nd cooked layer does not currently exist. The mapping from If we can't find a way for the REST API to keep the firmware bug workaround, the only other thing I can think of is that we add a way to enable/disable "quirks" from the command line, so the set of users who don't care about scenes can disable (let's say) [*] the other circumstance, when the light does not support |
I appreciate the dilemma. I’m sorry, I don’t have an answer. If memory serves, there was a similar problem for OSRAM colour temperature lights, but they don’t accept xy commands. I think they worked correctly when storing a scene from the current light state, but not when creating a scene while specifying the state (I need to brush up on the Scenes cluster commands). |
Interesting. Unless I'm misremembering it, the IKEA lights have the opposite bug in which they don't correctly store a scene from the current light state (which is the way you do it via deCONZ), unless the current light state was set via If the lights work correctly when you use "create scene", then it's possible that the workaround could be implemented for the scene creation step instead. This could have the additional benefit of working properly even when you set the light state via group commands, contrary to what happens today. |
I replaced the IKEA and OSRAM bulbs on my production network with Hue bulbs (because of the routing problems), but I still have them lying around, somewhere. I’ll see if I can do some tests over the weekend.
I think deCONZ also supports the other command, when you update the scene state. One of the hidden features in the API: deconz-rest-plugin/rest_groups.cpp Line 93 in ca72c46
|
Off-topic P.S.: This reminds me of an old idea that I have which is to introduce a device database to deCONZ. This device database will have entries mapping from a set of rules (MAC prefix, vendor, capabilities, firmware version, etc.) to a specific device entry. A device entry will have general information such as the device name, manufacturer, but most importantly: a set of quirks that apply. Then in every case in the code in which it has a special case or alternative behaviour guarded by Because at the beginning deCONZ might not have enumerated enough data to have an ideal mapping, every time new information is discovered that results in the device entry changing (let's say: from "IKEA light" to "IKEA GU10 WS light (firmware 3.x)" then the current best entry is saved to the DB. Device entries can be listed in order of most specific to most generic, and the first matched entry wins. So we could have a separate entry for lights with newer firmware that has less/different quirks than the same light with an old firmware. To make it manageable, we could also allow entries to specify a parent entry, so they inherit all the parent's quirks unless the device forcefully disables the quirk (example: "IKEA GU10 WS light" can inherit "IKEA WS light" which inherits from "IKEA light"). |
Indeed, this is what I mean by capability model. Preferably, I would be a JSON file, so new devices can be supported without code changes. I have something like that in Homebridge Hue, but very rudimentary and still in code. You can specify default quirks per manufacturer, overriding them per model, if needed. |
Agreed. If the DB is in a external file, it also immensely lowers the barriers for contributors. Code changes will be required only to implement entirely new quirks, but not to enable/disable existing quirks for certain devices. |
This turned out to be more challenging than I imaged. Summary:
Details: The REST API plugin is hugely inconsistent for scenes:
The Store Scene command sets the scene state to the current light state. The Add Scene and Enhanced Add Scene commands contain the scene state in their payload. The View Scene and Enhanced View Scene commands return the scene state, but the GUI doesn't display this, probably because the state is encoded in a kinda odd way. Different Color temperature lights seem to handle color temperature in scenes very differently. I've been testing the following lights:
Setting Color Temperature from the deCONZ GUI, following by a Store Scene:
Issuing Add Scene from the GUI is also handled differently. deCONZ issues a payload without any state attributes. This is valid, if I read the ZCL spec correctly, but WireShark thinks it's a malformed packet. The lights cannot seem to agree:
Issuing a PUT to
|
Great job. I just skimmed what you read because I'm extremely busy today (and will be on this weekend), but I'll come back to this and let's see if how I can contribute in improving the status quo. |
Some more reading in the ZCL spec (section 5.2.2.5):
Neither OSRAM, nor IKEA, nor icasa adhere to this. Kinda odd that they're still certified.
I'm not sure what "present but ignored" means, but this could be read as not even the Philips Hue light adheres to the standard (since they return only Current X and Current Y in the scene state). |
Looking at the code, this could only happen if the |
Patched the code, so it'll no longer send the malformed payload. Back to testing the IKEA. Indeed, setting Doing a PUT to the scene state now succeeds; the light returns only Current X and Current Y in the View Scene. However, when recalling the scene, these values seem to be igored, and the light reverts to the colour temperature from the last Store Scene. So the light seems to update its internal colour temperature on Move to Color, and stores it in the scene, without exposing this over ZigBee. For the icasa, the REST API sends Move to Color Temperature allright, when setting This seems to work, I can now PUT When doing a PUT to |
The scene handling is really confusing in the specification. I remember when implementing it for the FLS-PP lp RGBW ballast around 2013, it wasn't clear how to treat color temperature properly since it wasn't technically part of the scene. The add scene commands only carry xy values but no hint if it relates to color or color temperature. I can imagine that in the next API we could provide an option to recall scenes via unicast by just sending the related commands to set on/off, brightness and color based on the scene values stored in the database. Should work ok in smaller groups but scales badly for > 10'ish device groups, on the other hand it would solve the broadly broken firmware scene issues. |
Not a fan of "recalling" scenes through unicasts: this will be a lousy user experience, as the lights won't react simultaneously. If you want to go this route, make sure it's exposed differently in the API from recalling a ZigBee scene. I think the safe bet would be to stay away from Add Scene and to rely solely on (unicast) Store Scene commands to create and maintain scene light states. Most lights seem to support that alright. The only real limitation is that the 5-channel enhanced colour lights will drive the RGB channels (colormode |
One of my Homebridge Hue users has an issue that HomeKit doesn't reflect the colour temperature of their IKEA TW bulb correctly, see ebaauw/homebridge-hue#699. Did some more testing/sniffing on my Trådfri TW bulb (which seems to be a different model) When sending a Move to color temperature command, the light updates the Color temperature attribute to the actual setting (as opposed to the requested), but not Current x and Current y. On a subsequent Store scene, only Current x is reported in the scene, with the current (now bogus) value of Current x. However, when recalling the scene, the colour temperature is updated and Color temeperature shows the correct actual value. When sending a Move to color command, the light updates the Current x and Current y attributes to the actual settings, but not Color temperature. On a subsequent Store scene, both are reported in the scene, with the current values. Because Color temperature isn't updated, the REST API plugin reverts to the old value of I don't have any other IKEA TW lights, but it would seem that their recent firmwares have solved the issue for which the unholy hack has been introduced. deconz-rest-plugin/zcl_tasks.cpp Lines 392 to 394 in 1caed49
Even without the firmware fix, I think this hack does more harm than good, as the REST API reports the wrong colour temperature. |
After removing the cursed line, the REST API plugin behaves properly. A PUT of |
If recent firmwares can now save/recall |
@ebaauw: can you provide me the binary with the hack removed, so I don't need to compile by myself? I have 4 different models of IKEA lights, WS and CWS, I can test what happens with those. |
@lbschenkel What server do you run Homebridge on? What OS? |
Sorry, should have been more specific. I didn't mean Homebridge: I meant deCONZ. I would like to replicate your tests with the workaround disabled on all my lights, to confirm that latest firmware can save/recall scenes set via I'm running Debian "buster" x86-64. |
My bad. Doing too many things in parallel.
Sorry, I don't run that. I can only compile for Raspbian Stretch or Raspbian Buster on Raspberry Pi (armv7l). |
Remove unholy hack to set colour temperature for IKEA lights as xy, see #2507.
Included in a4c712b |
Commenting out this line of code should fix this issue.
#1861