[mqtt] Textual configuration results in flaky connection status
See original GitHub issueExpected Behavior
Changing a thing configuration file should not break the some things.
Current Behavior
Changing a thing configuration file, where items are already linked to channels (possibly not the root cause for the issue), results in errors, there the configured things are not able use the MQTT client.
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
Full configuration example for this is at [https://community.openhab.org/t/using-sonoff-power-switches-with-tasmota-firmware-and-openhab2-mqtt2-binding/](Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding).
Possible Solution
Based on a discussion on [https://community.openhab.org/t/reliability-of-binding-mqtt/59646/26](Reliability of binding-mqtt) the issue seems to be related to a timing problem while reloading the configuration. At the time, where the things are loaded and assigned to the bridge, the bridge is not fully connected or in ONLINE state.
Steps to Reproduce (for Bugs)
Not 100% sure. Please check the configuration on https://community.openhab.org/t/using-sonoff-power-switches-with-tasmota-firmware-and-openhab2-mqtt2-binding/](Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding). I don’t know, if this is reproducable for now.
Your Environment
- Ubuntu 18.04 Virtual Machine (VMware ESX), with openHAB unstable repository.
- openhab2 (2.4.0~S1461-1)
- bundle:list | grep “Eclipse SmartHome MQTT” 229 | Active | 80 | 0.10.0.201812141650 | Eclipse SmartHome MQTT Binding 230 | Active | 80 | 0.10.0.201812141650 | Eclipse SmartHome MQTT Thing Binding 238 | Active | 80 | 0.10.0.201812141650 | Eclipse SmartHome MQTT Transport Bundle
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (8 by maintainers)

Top Related StackOverflow Question
@davidgraeff - Can you provide a simple example? It is unclear to me how to do that since I define my thing inside of the Bridge which defines the broker?
For example, my config looks like this:
If I define the broker in a broker.thing file how do I avoid redefining it in the mqtt.thing file? In the blog post they are broken out, but the mqtt.thing defines parameters for the broker again.
You mean the JSONPATH transformation? Works perfectly and is automatically tested and documented as well.