[hue] Fix scene channel updating when scene is changed via Hue App#16001
[hue] Fix scene channel updating when scene is changed via Hue App#16001andrewfg wants to merge 4 commits intoopenhab:mainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
|
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/philips-hue-clip-2-api-v2-discussion-thread/142111/411 |
c573364 to
1e2f182
Compare
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>
54544bf to
babcf60
Compare
|
@jlaur for info, I will follow your test test case design from our other PR into this one.. |
jlaur
left a comment
There was a problem hiding this comment.
Thanks for the fix. I have added a few comments, most of which will probably be obsoleted by the changed test approach. 🙂
...binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/helper/Setters.java
Show resolved
Hide resolved
...binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/helper/Setters.java
Outdated
Show resolved
Hide resolved
...binding.hue/src/test/java/org/openhab/binding/hue/internal/clip2/SortSceneResourcesTest.java
Outdated
Show resolved
Hide resolved
...binding.hue/src/test/java/org/openhab/binding/hue/internal/clip2/SortSceneResourcesTest.java
Show resolved
Hide resolved
...binding.hue/src/test/java/org/openhab/binding/hue/internal/clip2/SortSceneResourcesTest.java
Outdated
Show resolved
Hide resolved
...binding.hue/src/test/java/org/openhab/binding/hue/internal/clip2/SortSceneResourcesTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
|
@andrewfg - looking at this again as well as these methods: I have a few questions:
If I read the code correctly, the new sequence (after sorting the resources) will now make us end up with the active scene rather than When both arrive in the same SSE event, I guess we can consider that atomic, and rather the swapping the order, perhaps we should actually discard the inactive scene when there is also an active scene. This, I guess, would result in a direct state update from the previously active scene to the new active scene. Changing to I'm not enough into scenes to understand how (and make If I understand the behavior correctly, we should avoid an intermediate state update to |
| assertEquals(5, list.size()); | ||
| assertEquals("0", list.get(0).getId()); | ||
| assertEquals("1", list.get(1).getId()); | ||
| assertEquals("2", list.get(2).getId()); | ||
| assertEquals("3", list.get(3).getId()); | ||
| assertEquals("4", list.get(4).getId()); |
There was a problem hiding this comment.
Ok. I will delete that.
|
@andrewfg - can you update the PR title to describe the bug being fixed rather than implementation details? |
|
@jlaur to answer your questions..
|
Why do you think that's right? On the contrary, if the scene is changed from A to B, I would expect to see exactly that in the event log: I would NOT expect to see: Do you agree that we can/should consider one SSE event as an atomic operation? I believe we should. You are right that it's very similar to #15905 in the way that we have asymmetry between the Hue API and the openHAB model. In the Hue API the order of scene active/scene inactive doesn't really matter when sent in the same event, since it's considered two different pieces of information. In our model we have only one channel to represent the currently active scene, not a channel for each scene to represent whether that scene is active or inactive. |
No I think it is not an atomic operation. I reality one scene was actually disabled. And another scene was enabled. As far as the scenes are concerned, and as far as the bridge is concerned there are indeed two separate events. I personally think we should not conflate those two events inside OH. |
I think this logic is flawed:
|
Ok. It means a complete rewrite of the PR.. |
Thank you @maniac103, this was exactly my point, but you described it in a much clearer way. 👍 |
|
As I say. This means a complete rewrite of the PR. It needs to check if both the scene deactivation and the scene activation event belong to the same room or zone. The SSE events contain sparse data so they don't have any information about which room or zone they belong to. Therefore it is impossible to do this fix with the current relatively minor changes at bridge level. Instead the room or zone information is only stored in the full resource information in the sceneCache of the respective things. This means that the elimination of the deactivation event that you are asking for must be done at thing level. Which means that the dispatch sequencing of the incoming events must be completely rewired. This is something that you @jlaur struggled with in the early stages of writing #15905 and eventually gave up doing. This is a massive structural change (for a relatively minor bug). Currently I don't have either the time or inclination to do this work. Certainly not before V4.1 release. So I offer you either of the two options..
Your choice. |
This doesn't sound like a binary decision. Why not do 1. now and 2. in the 4.2 timeframe? |
A preferable approach would be to cache the scenes in the bridge handler during the mass download phase.
Rather than deleting the whole resource, you would just delete its |
Yes, but I would leave that out the scope of that PR to reduce risk. After spending some time understanding the code, I have some general ideas about cache improvements that I'll share later.
If you have no hard objections to the approach, perhaps we could discuss details in the proposed PR? The reason I didn't change the status field is because that would (possibly) affect the cache. So to reduce risk, I went with the approach of simply skipping the channel update for undesired scene changes, but fully maintain the cache so that it represents the current state of all scenes. |
If you are intending to 'improve' the cache, we should know what you intend to do, before discussing your new scene PR. In any case, it reinforces my feeling that your scene PR cannot make it into v4.1 .. so @maniac103 suggestion might at least alleviate the bug (for non perfectionist users at least). |
It is not related to the scene PR, and I need to investigate and experiment some more before sharing my ideas/intentions.
I think @maniac103 made this suggestion before seeing that I already provided a better fix? I would therefore instead suggest that you have a look at the proposed fix. I think you are on the wrong track with this one. |
IMHO I am not on any track. |
I made it under the risk (or threat?) of the complete fix not landing in 4.1. I definitely do think it's better to have an incomplete fix than no fix at all, but I can't (and do not want to) asses the risks and merits of your both approaches. I rather wanted to mediate a bit from an outsider perspective ;-) Personal remark: I do think, though, that your (@andrewfg) tone is slightly passive aggressive to plain confrontative at times. Is this really necessary? |
@maniac103 yeah .. I learned that I have to do that with @jlaur .. otherwise he just ignores me .. and being a maintainer he overrules me. |
|
Closed in favour of #16018 |
Fixes #16000
Signed-off-by: Andrew Fiddian-Green software@whitebear.ch