openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.56k forks source link

[MQTT] OH3 Error: DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed. #8845

Closed LukasA83 closed 3 years ago

LukasA83 commented 3 years ago

Hi,

I'm sneak peeking into OH3 build #1980. Most my issues went away over the last builds, greatjob.

In my log I see ~ every minute this error: [ERROR] [ernal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

Is there anything wrong with my configuration or something wrong with the addon?

lolodomo commented 3 years ago

There is something badly implemented in the MQTT generic bonding which was cleverly detected by the core framework. It has to be fixed.

jochen314 commented 3 years ago

Can you please tell us more about this? What exactly is the contract of the DynamicStateDescriptionProvider and why is the current implementation so bad? A quick seach in the add-ons revealed multiple versions of teh DynamicStateDescriptionProvider, which are implemeneted the same way.

The (new) check in the core is:

if (stateDescription.equals(originalStateDescription))

What is so problematic about providing the equivalent stateDescription? The whole point is, that the stateDescription is not know before. So why is it bad, if it turns out to be the same as the static one? The only thing I see we san to do avoid this, is to move this exact test inside the MqttChannelStateDescriptionProvider or to the code feeding the stateDescription to this component.

But I still do not get the problem with this.

tomeng commented 3 years ago

Hi all,

I can second this issue (3.0.0 #2004).

It does occur whenever I command something to a player item (no matter what UI I use; linked to string mqtt thing) and this subsequently leads to the command not being send out to the mqtt broker.

To help with debug I have added the following on command rule -

var Log = Java.type("org.openhab.core.model.script.actions.Log");
Log.logInfo("event","--- MQTT Debug Start ---");
Log.logInfo("event",event.itemName);
Log.logInfo("event",event.itemState);
Log.logInfo("event",event.oldItemState);
Log.logInfo("event",event.command);
Log.logInfo("event",items[event.itemName]);
Log.logInfo("event","--- MQTT Debug End ---");

And I'm getting this log output

**==> /var/log/openhab2/events.log <==**
2020-11-03 13:00:56.252 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'Roon_AZHQ_Player' received command PLAY
2020-11-03 13:00:56.254 [INFO ] [rthome.event.ItemStatePredictedEvent] - Item 'Roon_AZHQ_Player' predicted to become PLAY
2020-11-03 13:00:56.256 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - 9f01e27507 updated: RUNNING
2020-11-03 13:00:56.256 [INFO ] [marthome.event.ItemStateChangedEvent] - Item 'Roon_AZHQ_Player' changed from PAUSE to PLAY
2020-11-03 13:00:56.272 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - 9f01e27507 updated: IDLE

**==> /var/log/openhab2/openhab.log <==**
2020-11-03 13:00:56.253 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.254 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.254 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.254 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.255 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.255 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.255 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.256 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.mqtt.generic.MqttChannelStateDescriptionProvider has to be fixed.

2020-11-03 13:00:56.266 [INFO ] [org.openhab.core.model.script.event ] - --- MQTT Debug Start ---

2020-11-03 13:00:56.267 [INFO ] [org.openhab.core.model.script.event ] - Roon_AZHQ_Player

2020-11-03 13:00:56.268 [INFO ] [org.openhab.core.model.script.event ] - undefined

2020-11-03 13:00:56.269 [INFO ] [org.openhab.core.model.script.event ] - undefined

2020-11-03 13:00:56.270 [INFO ] [org.openhab.core.model.script.event ] - undefined

2020-11-03 13:00:56.271 [INFO ] [org.openhab.core.model.script.event ] - PLAY

2020-11-03 13:00:56.272 [INFO ] [org.openhab.core.model.script.event ] - --- MQTT Debug End ---

Happy to help and provide further input if someone tells me what's needed :-)

Thanks for all your work, it's really appreciated!

lolodomo commented 3 years ago

Can you please tell us more about this?

@cweitkamp : could you please explain why it is a bug to do that in a binding ? I don't want to provide an approximative explanation.

cweitkamp commented 3 years ago

See e.g. https://github.com/openhab/openhab-addons/issues/3619.

The problem is that any dynamic state description state provider should return null when the requested channel is not handled by the binding. If it does not, it resets options for other bindings!

morph166955 commented 3 years ago

I just installed OH3 on a separate system to give it a test. I get this same error on both the Sonos and Sony Projector bindings.

2020-11-08 18:54:37.158 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.sonos.internal.SonosStateDescriptionOptionProvider has to be fixed. 2020-11-08 18:54:37.169 [ERROR] [rnal.ChannelStateDescriptionProvider] - Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. class org.openhab.binding.sonyprojector.internal.SonyProjectorStateDescriptionOptionProvider has to be fixed.

lolodomo commented 3 years ago

@cweitkamp : maybe a problem with the log in the core framework because I see no implementation problem in the sonos and SonyProjector bindings.

morph166955 commented 3 years ago

Something interesting to note on this. I have a bug open right now in relation to the Neeo binding https://github.com/openhab/openhab-addons/issues/8984

When I uninstalled and then installed the neeo transport, it caused all of the errors above to flood into the log. I'm not sure if it's possible that Neeo is causing this, but the installation of the transport triggers it.

J-N-K commented 3 years ago

@morph166955 This is unrelated. The NEEO IO requests the channels descriptions, that's why the errors occur, but it has nothing to do with the CNFE in #8984

cweitkamp commented 3 years ago

@lolodomo I rather tend to say this is an error in the BaseDynamicStateDescriptionProvider. It returns null if the pattern and the state options are null. I guess in the above mentioned case the state options list is empty too, which will lead to equal original state description and new state description returned by the provider. It additionally should return null if the state options list is empty.