Reliability of binding-mqtt

I would like to ask this question again, because I’m afraid this might get lost, but is essentially for me (currently I’m waiting for a response on this, before configuring everything through PaperUI). Just a hint would be great. Noone needs to create the whole configuration for me, based on my previously postest mqtt1 configuration.

Thanks in advance.

there are few users of MQTTv2 who have posted their MQTT.things configs. Check:

There were also a few more configs but I can’t find the posts atm.

I will also go for full text based configs when I decide to move away from MQTTv1 :slight_smile:

Maybe start a new thread with your examples to avoid going offtopic in this thread

@Dim Thank you very much! When I got this running, I will share my examples, as adivsed, in a new thread.

1 Like

OK. Just a short status update on the thing configuration. I got that working and I will post my solution later in a new topic. However, (@David_Graeff) for now it seems that the MQTT client behaves odd sometimes. Most of the times I saved the configuration file, the bridge or thing was in state offline or showed the state online, but in the mosquitto.log I could see that the client has disconnected after the connection was made. As a result controling my devices was not possible. After some more changes to the configuration file, everything was working properly again, but the issue occured again after additional changes. For now it seems, that after a warm restart of the openhab2 service does fix that problem.

Tomorrow I will try to dig deeper into this. If this issue only occurs after changing the configuration file but the service is working stable, that wouldn’t be something a big problem. If the client is unreliable as well, I will need to think about a workaround, as mentioned earlier by @StefanH.

I’ve created a new example topic of my currently running configuration: Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding

@David_Graeff it seems, that my things stop working with the message “No MQTT client”, if the linked item is changed or if the channel is changed, when there is already a linked item. I fetched the following logs, after changed my mqtt.things file:

2018-12-16 12:14:11.446 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt.things'

==> mosquitto/mosquitto.log <==
1544958851: Client paho439851773078352 disconnected.

==> openhab2/openhab.log <==
2018-12-16 12:14:11.529 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to 'x.x.x.x' with clientid paho481440911850144 and file store '/var/lib/openhab2/mqtt/x.x.x.x'

==> openhab2/events.log <==
2018-12-16 12:14:11.541 [hingStatusInfoChangedEvent] - 'mqtt:broker:MosquittoMqttBroker' changed from ONLINE to OFFLINE
2018-12-16 12:14:11.542 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs01' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.542 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs03' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.543 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs04' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.543 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs06' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.544 [hingStatusInfoChangedEvent] - 'mqtt:broker:MosquittoMqttBroker' changed from ONLINE to OFFLINE
2018-12-16 12:14:11.544 [me.event.ThingUpdatedEvent] - Thing 'mqtt:broker:MosquittoMqttBroker' has been updated.
2018-12-16 12:14:11.556 [hingStatusInfoChangedEvent] - 'mqtt:broker:MosquittoMqttBroker' changed from OFFLINE to ONLINE
2018-12-16 12:14:11.558 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs04' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.559 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs01' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.562 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs06' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.562 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs03' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.564 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs02' changed from UNINITIALIZED to INITIALIZING
2018-12-16 12:14:11.566 [me.event.ThingUpdatedEvent] - Thing 'mqtt:broker:MosquittoMqttBroker' has been updated.
2018-12-16 12:14:11.568 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs02' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client
2018-12-16 12:14:11.575 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs05' changed from UNINITIALIZED to INITIALIZING
2018-12-16 12:14:11.578 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs05' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client
2018-12-16 12:14:11.583 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs07' changed from UNINITIALIZED to INITIALIZING
2018-12-16 12:14:11.585 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs07' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client

Hope that helps to figure out the issue.

Everytime you change the Things file, the old Thing will be removed (the MqttBrokerConnection disconnects from Mosquitto) and a new Thing is created. The Thing has the same ID as before, and the correctly connects (ONLINE).

What apparently does not work reliable is the “Topic” Thing. This is also recreated on every file change. It does pick up the broker Thing. But it does not pick up the connection within the broker Thing, because that is not yet existing in exactly that millisecond. I will have a look into this.

Could you please create a bug report on Github as well? Title would be along the lines of “MQTT: Textual configuration results in flaky connection status” or so. And also refer to this post.

There is not much I can do before the OH 2.4 release I guess.

As long as this is working stable, I can handle those issues, because for now they only occur when changing the configuration.

I will create an issue on Github as requested. Thanks for your help!

Issue created: https://github.com/openhab/openhab2-addons/issues/4393

Just a short feedback: For now the MQTTv2 binding seems to work stable for me. At the time of writing it’s running for more than 24 hours without any change top openHAB2 (no configuration changes related to MQTT, no server reboots, no service restarts). For now it seems to work reliable and stable. :partying_face:

I will monitor this for a couple of days and mark the topic as solved, if there is no change in behavior.

@David_Graeff Thanks again for your help and work on this binding!! :+1::+1::+1:

1 Like