Skip to content
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

Dynamic state description broken in snapshot 1693 #1040

Closed
lolodomo opened this issue Sep 21, 2019 · 41 comments · Fixed by #1050
Closed

Dynamic state description broken in snapshot 1693 #1040

lolodomo opened this issue Sep 21, 2019 · 41 comments · Fixed by #1050
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@lolodomo
Copy link
Contributor

Dynamic state description is no more working, empty list are rendered by UI.
Default widget which should be a selection is no more working too, text widget is used.
This is probably a consequence of this recently merged PR:
#1010

The problem was introduced aftter snapshot 1678.
Coming back to snapshot 1678 until it is fixed.

@cweitkamp
Copy link
Contributor

Why did you think it is related to #1010?

@lolodomo
Copy link
Contributor Author

Because the choice of default widget depends on whether the state description is editable or not. It looks like now the state description seems to answer "not editable" while it should return "editable".
https://github.com/openhab/openhab-core/blob/master/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImpl.java#L244
https://github.com/openhab/openhab-core/blob/master/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImpl.java#L781
And it looks like the only very recent PR that was in relation to "editable".

@lolodomo
Copy link
Contributor Author

Additionally, I don't know if the editable property is important for the build of dynamic state options but apparently they are no more built correctly.

@cweitkamp
Copy link
Contributor

No, not really. The fix in #1010 addresses a editable property of the EnrichedItemDTO for the REST endpoint. It states when an item is managed by a ManagedItemProvider - meaning can it be removed via REST interface / is it managed via storage or is it configured by the user in a text file. This value is not related to the readOnly property of the StateDescription.

@lolodomo
Copy link
Contributor Author

OK. Were there other recent PRs impacting StateDescription ?

@cweitkamp
Copy link
Contributor

#908 touched parts of the StateDescriptionFragmentBuilder.

Did you test it with a specific binding?

@lolodomo
Copy link
Contributor Author

I saw it with Rotel and Sony Projector bindings. Forgot to check the Sonos binding as it seems to be a general bug.

@cweitkamp
Copy link
Contributor

Hm, interesting. I set-up a test on OH2 snapshot 1696 using avmfritz binding. It is working for me in Paper UI as well as in Basic UI. My sitemap contains a "Default" and a "Selection" element.

@lolodomo
Copy link
Contributor Author

lolodomo commented Sep 23, 2019

I just installed the snapshot 1698 and the problem is still there. The Sonos binding is impacted too, I can confirm it now.
Finally I don't thing the problem is the editable capability, I think the problem is that the lists of options are now always empty.

@lolodomo
Copy link
Contributor Author

How can we proceed ? Thîs bug is relatively critical. Revert the PR ?

@lolodomo
Copy link
Contributor Author

@cweitkamp : can you please help fixing this major issue breaking the use of several bindings ?
We could revert the PR at the origin of the problem ?

@cweitkamp
Copy link
Contributor

@lolodomo I would really love to help you. But as stated in #1040 (comment) I do not have a problem with avmfritz and Kodi bindings in latest snapshot 1701 in Paper UI / Basic UI - tested it again a few minutes ago.

Let us specify:

  • Which UI(s) is affected?
  • Is there a difference in the bindings implementation you are using and I am using? Unfortunately I do neither use the mentioned bindings nor have the chance to test them because of lack of devices. Can you add some logging in the affected bindings?
  • Do you see any chance to test one of avmfritz or Kodi binding on yourself?

@lolodomo
Copy link
Contributor Author

All UIs are impacted, at least Basic UI, Classic UI, Android App and Paper UI.
All bindings using dynamic state options are impacted, at least those I am using: Sonos, Rotel and Sony projector. All are using BaseDynamicStateDescriptionProvider.
What kind of logs do you want I add in the bindings ? Using BaseDynamicStateDescriptionProvider, there is not a lot of things inside the bindings.
I could try to install kodi but I should setup a kodi instance first...

@lolodomo
Copy link
Contributor Author

I could add logs in core UI to show you that the list of options is empty (or null ?) when requested (while it should not) ?
But apparently the bug is inside the core framework while the state description is handled.

@lolodomo
Copy link
Contributor Author

I can try to add logs in BaseDynamicStateDescriptionProvider...

@cweitkamp
Copy link
Contributor

Maybe we face a similar issue like https://github.com/openhab/openhab2-addons/issues/3619 (fixed by https://github.com/openhab/openhab2-addons/pull/3620)?

We could add logging to the following method to get some information about which DynamicStateDescriptionProvider is used to process the request:

private @Nullable StateDescription getDynamicStateDescription(Channel channel,
@Nullable StateDescription originalStateDescription, @Nullable Locale locale) {
for (DynamicStateDescriptionProvider provider : dynamicStateDescriptionProviders) {
StateDescription stateDescription = provider.getStateDescription(channel, originalStateDescription, locale);
if (stateDescription != null) {
return stateDescription;
}
}
return null;
}

I already talked to @Hilbrand about that. His detailed analysis showed that this logic "seems very inefficient and also error prone".

@lolodomo
Copy link
Contributor Author

lolodomo commented Sep 28, 2019

Here are some added logs:

12:55:11.374 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions channelUID rotel:rsp1066:preamp:source nb options 9
12:55:11.379 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions channelUID rotel:rsp1066:preamp:mainZone#source nb options 9
12:55:11.383 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions channelUID rotel:rsp1066:preamp:mainZone#recordSource nb options 8
12:55:11.387 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions channelUID rotel:rsp1066:preamp:zone2#source nb options 8
12:55:11.391 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions channelUID rotel:rsp1066:preamp:dsp nb options 13
12:55:11.395 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions channelUID rotel:rsp1066:preamp:mainZone#dsp nb options 13

when restarting the Rotel binding. We can see that options are set for channels.

Then later, when I go through Basic UI:

12:55:52.955 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:52.965 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:52.973 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:52.982 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
12:55:52.991 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9
12:55:53.003 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:53.010 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:53.020 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:53.028 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
12:55:53.037 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9
12:55:53.047 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:53.056 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:53.064 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
12:55:53.072 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
12:55:53.080 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9

getStateDescription from BaseDynamicStateDescriptionProvider is called several times for the same channel. Sometimes, it returns options; sometimes it doesn't !
Does it help ?

@cweitkamp
Copy link
Contributor

Yes, it is a step forward. Can you add this.getClass() to the output of the logger in the getStateDescription() method?

@lolodomo
Copy link
Contributor Author

@lolodomo
Copy link
Contributor Author

Here are:

2019-09-28 13:22:30.910 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.netatmo.internal.NATherm1StateDescriptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
2019-09-28 13:22:30.915 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
2019-09-28 13:22:30.920 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9
2019-09-28 13:22:30.930 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.netatmo.internal.NATherm1StateDescriptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
2019-09-28 13:22:30.934 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
2019-09-28 13:22:30.939 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9
2019-09-28 13:22:30.945 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.netatmo.internal.NATherm1StateDescriptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
2019-09-28 13:22:30.949 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
2019-09-28 13:22:30.953 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9
2019-09-28 13:22:30.960 [DEBUG] [.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.netatmo.internal.NATherm1StateDescriptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource pattern null nb options null

Ok this is the Netatmo binding dynamic options state provider that provides null.
Would the provider form Netatmo be used in state of the rotel one ?

@lolodomo
Copy link
Contributor Author

lolodomo commented Sep 28, 2019

In fact, any other bidnings (Sonos, Netatmo, Sony projector) is called and of course returns null as options for this channel; only the rotel provider provides options.
After stopping the Netatmo binding:

13:30:04.007 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.sonos.internal.SonosStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
13:30:04.014 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.sonyprojector.internal.SonyProjectorStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
13:30:04.021 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
13:30:04.027 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9
13:30:04.038 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.sonos.internal.SonosStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
13:30:04.045 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.sonyprojector.internal.SonyProjectorStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
13:30:04.051 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
13:30:04.060 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9
13:30:04.071 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.sonos.internal.SonosStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
13:30:04.077 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.sonyprojector.internal.SonyProjectorStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options null
13:30:04.086 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
13:30:04.093 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result min null max null step null pattern %s nb options 9

Maybe core UI is not getting the correcr provider ?

@lolodomo
Copy link
Contributor Author

Even if I stop the other bindings, still not working.
I will add in the logs the readonly property...

@cweitkamp
Copy link
Contributor

cweitkamp commented Sep 28, 2019

One more guess - Can you change the logging in setStateOptions() to log the StateOption (label, value) instead of the size? I want to make sure that all labels are set correctly.

@lolodomo
Copy link
Contributor Author

readOnly is false as expected.

@lolodomo
Copy link
Contributor Author

No problem with setting options:

14:02:00.626 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource nb options 8
14:02:00.630 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label CD value CD
14:02:00.634 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label TUNER value TUNER
14:02:00.638 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label TAPE value TAPE
14:02:00.642 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label LD value VIDEO1
14:02:00.646 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label HDDVD value VIDEO2
14:02:00.649 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label PS3 value VIDEO3
14:02:00.653 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label TV value VIDEO4
14:02:00.656 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#recordSource option label VID 5 value VIDEO5
14:02:00.661 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source nb options 8
14:02:00.664 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label CD value CD
14:02:00.668 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label TUNER value TUNER
14:02:00.671 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label TAPE value TAPE
14:02:00.675 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label LD value VIDEO1
14:02:00.678 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label HDDVD value VIDEO2
14:02:00.681 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label PS3 value VIDEO3
14:02:00.685 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label TV value VIDEO4
14:02:00.688 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:zone2#source option label VID 5 value VIDEO5
14:02:00.692 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp nb options 13
14:02:00.697 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label No DSP value NONE
14:02:00.701 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Dolby 3 Stereo value STEREO3
14:02:00.706 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label 5 Channel Stereo value STEREO5
14:02:00.709 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label 7 Channel Stereo value STEREO7
14:02:00.714 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Music 1 value MUSIC1
14:02:00.717 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Music 2 value MUSIC2
14:02:00.721 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Music 3 value MUSIC3
14:02:00.724 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Music 4 value MUSIC4
14:02:00.728 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Dolby Pro Logic value PROLOGIC
14:02:00.731 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Dolby PLII Cinema value PLIICINEMA
14:02:00.735 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label Dolby PLII Music value PLIIMUSIC
14:02:00.738 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label dts Neo:6 Cinema value NEO6CINEMA
14:02:00.742 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:dsp option label dts Neo:6 Music value NEO6MUSIC
14:02:00.746 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp nb options 13
14:02:00.751 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label No DSP value NONE
14:02:00.755 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Dolby 3 Stereo value STEREO3
14:02:00.760 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label 5 Channel Stereo value STEREO5
14:02:00.764 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label 7 Channel Stereo value STEREO7
14:02:00.769 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Music 1 value MUSIC1
14:02:00.773 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Music 2 value MUSIC2
14:02:00.778 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Music 3 value MUSIC3
14:02:00.782 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Music 4 value MUSIC4
14:02:00.787 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Dolby Pro Logic value PROLOGIC
14:02:00.791 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Dolby PLII Cinema value PLIICINEMA
14:02:00.796 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label Dolby PLII Music value PLIIMUSIC
14:02:00.800 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label dts Neo:6 Cinema value NEO6CINEMA
14:02:00.807 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - setStateOptions class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#dsp option label dts Neo:6 Music value NEO6MUSIC

@lolodomo
Copy link
Contributor Author

I missed one of your message. I will add logs to getDynamicStateDescription.

@lolodomo
Copy link
Contributor Author

14:22:05.086 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
14:22:05.096 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result readOnly false min null max null step null pattern %s nb options 9
14:22:05.107 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source original nb options 0
14:22:05.116 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source result nb options 9
14:22:05.127 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
14:22:05.134 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result readOnly false min null max null step null pattern %s nb options 9
14:22:05.142 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source original nb options 0
14:22:05.148 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source result nb options 9
14:22:05.157 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
14:22:05.165 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result readOnly false min null max null step null pattern %s nb options 9
14:22:05.174 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source original nb options 0
14:22:05.180 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source result nb options 9

The method getDynamicStateDescription seems to return options but we can see that the parameter "original" has no options. Is it expected ?

@lolodomo
Copy link
Contributor Author

The problem seems to be in the core UI where I got 0 state options for the item. I am adding logs in this place now.

@lolodomo
Copy link
Contributor Author

The state description got no options !

14:54:29.193 [DEBUG] [.ui.internal.items.ItemUIRegistryImpl] - getNbOptions preamp_source
14:54:29.203 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
14:54:29.211 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result readOnly false min null max null step null pattern %s nb options 9
14:54:29.219 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source original nb options 0
14:54:29.226 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source result nb options 9
14:54:29.235 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source pattern null nb options 9
14:54:29.243 [DEBUG] [g.BaseDynamicStateDescriptionProvider] - getStateDescription class class org.openhab.binding.rotel.internal.RotelStateDescriptionOptionProvider channelUID rotel:rsp1066:preamp:mainZone#source result readOnly false min null max null step null pattern %s nb options 9
14:54:29.251 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source original nb options 0
14:54:29.259 [DEBUG] [ernal.ChannelStateDescriptionProvider] - getDynamicStateDescription channel rotel:rsp1066:preamp:mainZone#source result nb options 9
14:54:29.266 [DEBUG] [.ui.internal.items.ItemUIRegistryImpl] - getNbOptions stateDescription StateDescription [minimum=null, maximum=null, step=null, pattern=%s, readOnly=false, channelStateOptions=[]]
14:54:29.274 [DEBUG] [.ui.internal.items.ItemUIRegistryImpl] - getNbOptions stateDescription readOnly false nb options 0
14:54:29.281 [DEBUG] [.ui.internal.items.ItemUIRegistryImpl] - getNbOptions nbCommandOptions 0 nbStateOptions 0 result 0

You can find the code of getNbOptions with the additional logs here:
https://github.com/lolodomo/openhab-core/blob/dynamicOptions/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImpl.java#L790

@lolodomo
Copy link
Contributor Author

@cweitkamp : this would lead to there:
https://github.com/openhab/openhab-core/blob/master/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/service/StateDescriptionServiceImpl.java#L87
It looks like we are approaching your updated code ?
I am not understanding all this stuff with fragment and merge...

@lolodomo
Copy link
Contributor Author

I think I found the bug. The issue is here:
https://github.com/openhab/openhab-core/blob/master/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/types/StateDescriptionFragmentImpl.java#L190
It ignores the new options when this.options is not null but an empty list.
@cweitkamp : I imagine the test should rather be this.options == null || this.options.isEmpty() ? I try

@lolodomo
Copy link
Contributor Author

Bingo, it is working with this change.
I will submit the fix but I let you check more globally, you are more aware than me about this part.

@cweitkamp
Copy link
Contributor

cweitkamp commented Sep 28, 2019

Nice catch. Some seconds faster than me: 9e16bc1

@cweitkamp
Copy link
Contributor

And of course thank you very much for your research. Very much appreciated.

cweitkamp pushed a commit that referenced this issue Sep 28, 2019
* Fix dynamic options in UI
* Added unit tests

Fixes #1040

Also-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@cweitkamp cweitkamp added the bug An unexpected problem or unintended behavior of the Core label Sep 28, 2019
@lolodomo
Copy link
Contributor Author

I can confirm everything is ok again in snapshot 1703.

@timbms
Copy link

timbms commented Oct 14, 2019

@cweitkamp @lolodomo : I want to implement the dynamic mappings feature for the iOS app. I have already a PR. Can you let me know which binding is using the dynamic mappings? Is avmfritz making use of dynamic mappings? If so, which feature is using it?

@cweitkamp
Copy link
Contributor

which binding is using the dynamic mappings?

Have a look here to find out which bindings make use of this feature.

Is avmfritz making use of dynamic mappings?

Yes, it does. The FRITZ!Box (fritzbox) thing type has a channel apply_template which is populated dynamically when a user has defined templates ("Vorlagen") for his Smart Home devices (see FRITZ! Smart Home Templates section from the docs).

@timbms
Copy link

timbms commented Oct 17, 2019

Thank you @cweitkamp
Took me some time to find out that this is not available with openhab 2.4.
In the meantime I installed a docker container with openhab 2.5.0M3.
Are there different types of dynamic mappings? avmfritz uses Selection. But code in android apps suggests that it may also be a Switch. Who can help on this?

@cweitkamp
Copy link
Contributor

Yes, there are different types of mapping. We distinguish between State and Command Descriptions. UIs should will render a Selection for Default elements. Selection and Switch elements are both valid. See #952 for more information - fair warning tl;dr). I guess @lolodomo can tell you a lot more about this.

@timbms
Copy link

timbms commented Oct 20, 2019

@cweitkamp: I have seen even a third variant: Spotify Binding uses a Frame element. I
iOS app will have to follow the lead

timbms added a commit to openhab/openhab-ios that referenced this issue Oct 20, 2019
… agreed one of for basic ui and android : openhab/openhab-core#952, openhab/openhab-core#1040

Signed-off-by: Tim Müller-Seydlitz <timbms@gmail.com>
timbms added a commit to openhab/openhab-ios that referenced this issue Oct 20, 2019
… agreed one of for basic ui and android : openhab/openhab-core#952, openhab/openhab-core#1040 (#483)

Signed-off-by: Tim Müller-Seydlitz <timbms@gmail.com>
@cweitkamp
Copy link
Contributor

I have seen even a third variant: Spotify Binding uses a Frame element.

Can you provide me a link, a screenshot or an example?

splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this issue Jul 11, 2023
* Fix dynamic options in UI
* Added unit tests

Fixes openhab#1040

Also-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
GitOrigin-RevId: 7b49f27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants