-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Update of dynamic state options in UIs is broken #2409
Comments
What does that mean exactly? How can I reproduce this? Can you elaborate a little bit? |
Just run the current code or the snapshot 2431. For an untouched binding (I checked the home connect binding), it even looks like the state options are not set at all. I would like to be sure that it is not due to outdated UIs not in phase with the new core code before investigating/debugging in Eclipse. |
In Eclipse, I see resolution with core.thing.3.1.0.202106211206 and ui.basic.3.1.0.202106201606. |
Same in build 2431:
I hope we just need to rebuild all the UIs. |
I have started a new build of the UI against the latest core: https://ci.openhab.org/job/openHAB-WebUI/360/ |
Thank you, I just noticed the rebuild in progress. |
Unfortunately, the issue is still there in snapshot 2433 :( Could you check and confirm @cweitkamp ? I could restore an older snapshot from few days to be sure what broke the feature. |
I have now restored the snapshot 2415 and the problem is still there ! |
I have one strange feeling: just by reading the code, it looks like itemdtomapper is setting item command description with state options when no command options are available. We must not store command description when there is none. We must not create one from the state description. Here is the suspected line: Line 101 in 79edf2b
|
After introduction of the Is your Item read-only? This imo is the only situation where the above logic does not make sense. |
No my item is not read-only. |
If I use the API explorer and requests the data for my item, I can see a |
I tried to reproduce your issue with latest code via Eclipse and Kodi binding which uses both (a I am not sure how I can help you. Can you provide code? An example configuration? Screenshots? |
That is creazy ! With snapshot 2433, after the startup, the state options of my Sonos item listing my favorite radio stations is correctly set:
Then I remove one of my favorite radio using the Sonos app. I see the expected new event logged:
The event shows that the number of options goes from 13 to 12, as expected. But then:
I used "Ctrl+F5" in Firefox but unchanged. |
If I open UI using Edge, I still see 13 options. So this is not due to the browser. For me, it is clear, the item state description was not updated. The first setting is always OK but then the next updates are not impacting the item data (while the produced .ChannelDescriptionChangedEvent event is correct). |
In my last test, I simply use the 2433 distirbution with absolutely no code modification. |
I extended my Sonos dynamic state options provider to see when it is called. |
I am sure there is BIG bug, certainly subtile. Unfortunately, I am not clear how to debug that. This is of course somewhere in the core framework but all this is very complex (service, fragment, provider, registry, ...). I am a little lost. @cweitkamp : did you try to trigger several updates of your options ? |
I also added logs in the BasicUI backend, that is in the render of my selection widget called when I open the page containing my item. At init, I first see:
My state options are correctly loaded by the Sonos binding. Then I open BasicUI:
That is OK, the call to item.getCommandDescription() is requesting my Sonos dynamic option provider and finally returns the correct number of options (12). Then in the Sonos app, I removed a favorite station. I see the update of state options by the Sonos dynamic option provider:
And now I reopen BasicUI:
Here is the problem. You can see that my Sonos dynamic option provider is requested and provided 11 options but finally the returned command description contains 12 options and UI page is built with that. By curiosity, I also called item.getStateDescription() in the selection renderer but the result is the same:
So item.getCommandDescription() and item.getStateDescription() run by the BasicUI widget renderer are returning a bad list of options. |
@cweitkamp : ok, I am making progress. I have now added logs in CommandDescriptionServiceImpl and StateDescriptionServiceImpl. This is a use case when I added a favorite radio station. In fact, I discovered that there are two state description fragments returned for my item.
I have 3 fragment providers. Don't know if this is normal. These 2 fragment providers returning a different number of options is clearly the cause of my problem. Or if the both fragments is something normal, maybe the problem is their merge ? |
Can you identify which provider are running in your system? Call from Karaf console:
|
My detailed tests were run inside Eclipse and I can't run such command.
|
In my Eclipse setup, I should in theory have 2, one for sonos and one for remoteopenhab. And one provider attached to the CommandDescriptionServiceImpl is certainly coming from remoteopenhab binding; don't know for the second. |
I will check this evening the type of each of my StateDescriptionFragmentProvider.. Will see which one delivers the wrong information. |
Here is with enhanced logs (scenario when I removed a favorite stations, going from 12 to 11 stations):
As you can see, the two fragment providers are GenericItemProvider and ChannelStateDescriptionProvider. Any idea why GenericItemProvider delivers wrong information ? It delivers the dynamic options but the old ones. Looking at the code of the merge of fragments, the list of options of second fragment are just ignored if the first fragment has already options. It clearly explains why the final state description contains 12 options. So the result depends on the order of fragment providers. Maybe, the order is the reverse sometimes and it would explain why it works for some users. PS: I have now only the Sonos binding setup in Eclipse. |
I also checked the rank of each fragment provider:
Is it expected that GenericItemProvider returns dynamic state options ? Not the most uptodate ? If it is, maybe we should consider the rank when going through the fragment providers ? And dgive priority to ChannelStateDescriptionProvider ? Line 70 in 79edf2b
@cweitkamp @kaikreuzer : I think the analysis is now relatively clear. WDYT ? |
Can I have please attention, it looks like a major bug and I would recommend to fix it before releasing 3.1. |
As a workaround, we can update the code to be sure that GenericItemProvider will be handled after ChannelStateDescriptionProvider by StateDescriptionServiceImpl. At least, this will fix the display of options in Basic UI. |
In fact the fragment providers are already sorted in the reverse order of their rank: Line 43 in 79edf2b
So the order is the same for everybody. GenericItemProvider is handled before ChannelStateDescriptionProvider . |
@lolodomo First of all I'd like to point out that you got my attention from the first time you opened this issue. Second I'd like to thank you for your deep analysis. The Lines 77 to 81 in 8e3f87a
When Solution is to create a deep copy of the first found fragment before merging other fragments into it. |
That was my feeling too. |
@cweitkamp : we have a major issue. The update of state options in UIs is now broken in snapshot 2431.
This is certainly a consequence of PR #1505
Note that the new event is working well, I was able to catch it in the remote openHAB binding.
The problem is that after you update your state options provider for a channel, this update is ignored in UIs (Main UI and Basic UI). And this is not a cache problem of course.
Could it be because the webui is not yet in phase with the core changes ?
The text was updated successfully, but these errors were encountered: