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

Kodi: bug in the dynamic state description provider #3619

Closed
lolodomo opened this issue Jun 2, 2018 · 13 comments
Closed

Kodi: bug in the dynamic state description provider #3619

lolodomo opened this issue Jun 2, 2018 · 13 comments

Comments

@lolodomo
Copy link
Contributor

lolodomo commented Jun 2, 2018

The implementation of the Kodi dynamic state desciption provider has a major issue.
https://github.com/openhab/openhab2-addons/blob/master/addons/binding/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/internal/KodiDynamicStateDescriptionProvider.java#L43
When the service is called for a channel of another binding, it returns the original state description but resetting the options.
It should return null in case the channel is not handled by the Kodi binding.

This has been discovered when trying to implement this feature: eclipse-archived/smarthome#4942

I will provide a fix.

@martinvw
Copy link
Member

martinvw commented Jun 2, 2018

@cweitkamp fyi

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 2, 2018

Note that such provider implemented by a binding could directly impact the channels of other bindings.
It was what was happening due to this bug, the state options were reset for all the channels in the system except the Kodi channel.

Note that it is a MAJOR bug but only for users using this binding.

@martinvw
Copy link
Member

martinvw commented Jun 2, 2018

IMHO we should also look into fixing or very explicitly documenting this behavior because null seems to mean something very specific in this case. Normally i see such patterns combined with something like an isSupported method.

martinvw pushed a commit that referenced this issue Jun 2, 2018
@mhilbush
Copy link
Contributor

mhilbush commented Jun 2, 2018

I expect the squeezebox binding also may have the same issue.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 2, 2018

I searched for DynamicStateDescriptionProvider and only found it in the Kodi binding. But maybe the squeezebox binding was not loaded in my IDE.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 2, 2018

squeezebox binding is ok but I found the same issue in the Hyperion binding. The loxone binding is certainly to be investigated because very strange. Amazonecho is unusual too.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 2, 2018

Amazonecho is ok as the channel type is checked. It returns original rather than null but it is ok too.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 2, 2018

loxone binding is finally ok.
I created a PR for the hyperion binding.
All other bindings look good.

@cweitkamp
Copy link
Contributor

Thanks for taking care of this. I can confirm that it works now.

I removed those lines in #3505 because my IDE complains about an unnecessary null check like it does now again. We have to change the annotations for this class as well.

[WARNING] ~/openhab2-addons/addons/binding/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/internal/KodiDynamicStateDescriptionProvider.java:[47] 
	if (options == null) {
	    ^^^^^^^
Null comparison always yields false: The variable options cannot be null at this location
1 problem (1 warning)

bildschirmfoto vom 2018-06-03 11-48-09

Suggestion - Let us change
https://github.com/openhab/openhab2-addons/blob/6f2212251087413fddb61608256c75b1af3a01cd/addons/binding/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/internal/KodiDynamicStateDescriptionProvider.java#L36
to

private final Map<ChannelUID, @Nullable List<StateOption>> channelOptionsMap = new ConcurrentHashMap<>(); 

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 3, 2018

Can you please apply the change in all concerned bindings ?

@cweitkamp
Copy link
Contributor

@lolodomo @martinvw Done. PR #3623.

@tavalin
Copy link

tavalin commented Jun 3, 2018

I based the Hyperion implementation of the dynamic state description service on the Kodi binding as an example so it's likely affected too.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 3, 2018

@tavalin : yes, it is already fixed.

ssalonen pushed a commit to ssalonen/openhab2-addons that referenced this issue Jun 25, 2018
hww3 pushed a commit to hww3/openhab2-addons that referenced this issue Jul 4, 2018
divyachauhan25 pushed a commit to divyachauhan25/openhab2-addons that referenced this issue Jul 6, 2018
cweitkamp referenced this issue in Hilbrand/openhab-addons Aug 20, 2019
Hilbrand added a commit to Hilbrand/openhab-addons that referenced this issue Aug 20, 2019
Don't return originalStateDescription as the service code depends on it being null if the specific provider called isn't handling the channel. See openhab#3619

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
kaikreuzer pushed a commit that referenced this issue Aug 21, 2019
Don't return originalStateDescription as the service code depends on it being null if the specific provider called isn't handling the channel. See #3619

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
chaton78 pushed a commit to chaton78/openhab-addons that referenced this issue Sep 2, 2019
Don't return originalStateDescription as the service code depends on it being null if the specific provider called isn't handling the channel. See openhab#3619

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
Signed-off-by: Pascal Larin <[email protected]>
ne0h pushed a commit to ne0h/openhab-addons that referenced this issue Sep 15, 2019
Don't return originalStateDescription as the service code depends on it being null if the specific provider called isn't handling the channel. See openhab#3619

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
Signed-off-by: Maximilian Hess <[email protected]>
Pshatsillo pushed a commit to Pshatsillo/openhab-addons that referenced this issue Dec 8, 2019
Don't return originalStateDescription as the service code depends on it being null if the specific provider called isn't handling the channel. See openhab#3619

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
tmrobert8 pushed a commit to tmrobert8/openhab-addons that referenced this issue Jan 21, 2020
Don't return originalStateDescription as the service code depends on it being null if the specific provider called isn't handling the channel. See openhab#3619

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
Signed-off-by: Tim Roberts <[email protected]>
hww3 pushed a commit to hww3/openhab2-addons that referenced this issue Feb 22, 2020
Don't return originalStateDescription as the service code depends on it being null if the specific provider called isn't handling the channel. See openhab#3619

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants