openHAB 2.2 binding MQTT support
-
Thank you @dakipro for your feedback!
I've updated the jar-file above. It is now possible to autodiscover a gateway if the corresponding broker is connected to OpenHab2.

At first glance the smarthome-mqtt and the (old) openhab-mqtt seem to work together, I've had no problem configuring both in the same instance. Of course this means we need mqtt.cfg AND org.eclipse.smarthome.mqtt.cfg.
Yeah, FOTA support would definatly be nice to have, but I'm not yet using it in my MySensors environment, so I first need to figure out how it works. :-)
-
That is great, I've been a bit inactive with mysensors (moving and family and things) but it should be now possible to ask gateway to present all nodes (ask nodes to present themselves) and add them as things/items?
I personally prefer to have items configured in the files, but having them autodetected via mqtt and added trough paperUi is definitely an awesome feature, completes the integration via plugin and its functionality.I've played yesterday with MyController https://www.mysensors.org/controller/mycontroller and I've seen that it has support for all those things over mqtt (get items info, auto add them). It can also do FOTA over mqtt, something no other controller is capable of doing today (not even famous MySController that originally introduces FOTA). I am sure you can find some inspiration in MyController code about how it is done, when the time comes :)
My plan was to use MyController only for maintenance and remote update of nodes, but unfortunately I wasn't able to set it up to work, got a bunch of exceptions when I tried to add nodes to it. I will try previous version, but if this would be supported in openhab, that would benefit both platforms, a LOT :)
-
First of all, I'd like to thank you for your contribution, it is greatly appreciated!
Unfortunately, I could not get the binding to talk to my Mosquitto server, yet. I have installed the addon and configured my MySensors MQTT Gateway as described above. But when I start OpenHAB (the Docker container instantiated from "openhab/openhab:2.2.0-amd64-alpine" to be precise), this is what I get in the openhab.log file:
2018-01-09 15:45:29.710 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed. 2018-01-09 15:45:29.711 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'ineluki' 2018-01-09 15:45:30.420 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - No connection to broker: ineluki 2018-01-09 15:45:30.471 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:0)And there is no "retry" after 10 seconds. At the same time this is and only this logged by Mosquitto:
1515512709: Socket error on client openhab, disconnecting. 1515512729: New connection from 172.19.0.5 on port 1883.Do you have any clue or hint what I might be doing wrong? I'm entirely new to OpenHAB, so please excuse if I'm missing something obvious.
-
First of all, I'd like to thank you for your contribution, it is greatly appreciated!
Unfortunately, I could not get the binding to talk to my Mosquitto server, yet. I have installed the addon and configured my MySensors MQTT Gateway as described above. But when I start OpenHAB (the Docker container instantiated from "openhab/openhab:2.2.0-amd64-alpine" to be precise), this is what I get in the openhab.log file:
2018-01-09 15:45:29.710 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed. 2018-01-09 15:45:29.711 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'ineluki' 2018-01-09 15:45:30.420 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - No connection to broker: ineluki 2018-01-09 15:45:30.471 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:0)And there is no "retry" after 10 seconds. At the same time this is and only this logged by Mosquitto:
1515512709: Socket error on client openhab, disconnecting. 1515512729: New connection from 172.19.0.5 on port 1883.Do you have any clue or hint what I might be doing wrong? I'm entirely new to OpenHAB, so please excuse if I'm missing something obvious.
Hi @cgrf !
Please post the content of "org.eclipse.smarthome.mqtt.cfg".
My guess is: there is no connection between OpenHAB2 and Mosquitto. The binding is only using the connection, it is not in charge for establishment or reconnects.Please check that in org.eclipse.smarthome.mqtt.cfg :
mosquitto.url=tcp://192.168.2.3:1883 mosquitto.user=user mosquitto.pwd=secret mosquitto.retain=falseand in the MQTT GW configuration (in OH2) the names are matching.
In your case it should look like (or similar to):
ineluki.url=tcp://172.19.0.5:1883 ineluki.user=user ineluki.pwd=secret ineluki.retain=false -
Hi @TimO,
Thanks for your response! There is an incoming connection from OpenHAB to Mosquitto, I can see as much in the Mosquitto log. But that connection does not seem to succeed.
This is the content of my mqtt.cfg:
ineluki.url=tcp://192.168.5.2:1883 ineluki.clientId=openhab ineluki.qos=2 ineluki.retain=trueThat Mosquitto instance currently does not require users to authenticate.
-
Hi @TimO,
Thanks for your response! There is an incoming connection from OpenHAB to Mosquitto, I can see as much in the Mosquitto log. But that connection does not seem to succeed.
This is the content of my mqtt.cfg:
ineluki.url=tcp://192.168.5.2:1883 ineluki.clientId=openhab ineluki.qos=2 ineluki.retain=trueThat Mosquitto instance currently does not require users to authenticate.
Is there a log entry in OpenHAB that looks like this?
[DEBUG] [.io.transport.mqtt.MqttService:155 ] - Starting MQTT Service... [INFO ] [.i.t.mqtt.MqttBrokerConnection:576 ] - Starting MQTT broker connection 'mosquitto' to 'tcp://192.168.2.3:1883' with clientid paho6110733874326 and file store '/tmp/mosquitto' [DEBUG] [.io.transport.mqtt.MqttService:155 ] - Starting MQTT Service... [INFO ] [.i.t.mqtt.MqttBrokerConnection:576 ] - Starting MQTT broker connection 'mosquitto' to 'tcp://192.168.2.3:1883' with clientid paho6110762725063 and file store '/tmp/mosquitto'Depending on your log level there only may be the INFO line.
-
I have this INFO line, as included in my first post, that looks similar but not quite the same:
2018-01-09 15:45:29.711 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'ineluki'The four lines from my first post are actually all lines I have in that log after the UI start-up messages.
-
@cgrf said in openHAB 2.2 binding MQTT support:
Starting MQTT broker connection
You're using the mqtt1 (openhab1-addon) to connect to the broker. The OpenHAB2 binding is based on the current (/upcoming) mqtt-transport implementation of ESH.
My guess: the file org.eclipse.smarthome.mqtt.cfg is missing in /etc/openhab2/services and there only is a mqtt.cfg file. Just copy the mqtt.cfg file to org.eclipse.smarthome.mqtt.cfg (Same content, different name, different use).
mqtt.cfg: mqtt1 binding, mqtt-transport, owntracks ...
org.eclipse.smarthome.mqtt.cfg: ESH-MQTT and I'm only aware of my binding using it yet. But there are a few upcoming (mqtt generic, mqtt2 binding ..)
-
@cgrf said in openHAB 2.2 binding MQTT support:
Starting MQTT broker connection
You're using the mqtt1 (openhab1-addon) to connect to the broker. The OpenHAB2 binding is based on the current (/upcoming) mqtt-transport implementation of ESH.
My guess: the file org.eclipse.smarthome.mqtt.cfg is missing in /etc/openhab2/services and there only is a mqtt.cfg file. Just copy the mqtt.cfg file to org.eclipse.smarthome.mqtt.cfg (Same content, different name, different use).
mqtt.cfg: mqtt1 binding, mqtt-transport, owntracks ...
org.eclipse.smarthome.mqtt.cfg: ESH-MQTT and I'm only aware of my binding using it yet. But there are a few upcoming (mqtt generic, mqtt2 binding ..)
@timo said in openHAB 2.2 binding MQTT support:
My guess: the file org.eclipse.smarthome.mqtt.cfg is missing
Excellent guess, that was my problem! My gateway is "online" now. It would have taken me forever to figure that out on my own, so thank you very much! (And yes, reading your first post now I realize that you said so.)
Should OpenHAB be able to discover the sensors behind the gateway? Or do I need to configure them manually?
-
@timo said in openHAB 2.2 binding MQTT support:
My guess: the file org.eclipse.smarthome.mqtt.cfg is missing
Excellent guess, that was my problem! My gateway is "online" now. It would have taken me forever to figure that out on my own, so thank you very much! (And yes, reading your first post now I realize that you said so.)
Should OpenHAB be able to discover the sensors behind the gateway? Or do I need to configure them manually?
-
@TimO
Ok, I've restarted the sensor multiple times now and I assume that it presents itself properly as it is discovered by other controllers (mycontroller.org, that is). But in OpenHAB's PaperUI it doesn't show up at all. There is a trace of it in the openhab.log though:2018-01-10 09:29:39.268 [WARN ] [al.sensors.child.MySensorsChildSTemp] - Overwrite variable: V_VAR1 2018-01-10 09:29:39.269 [WARN ] [al.sensors.child.MySensorsChildSTemp] - Overwrite variable: V_VAR2 2018-01-10 09:29:39.277 [WARN ] [al.sensors.child.MySensorsChildSTemp] - Overwrite variable: V_VAR3 2018-01-10 09:29:39.289 [WARN ] [al.sensors.child.MySensorsChildSTemp] - Overwrite variable: V_VAR4 2018-01-10 09:29:39.289 [WARN ] [al.sensors.child.MySensorsChildSTemp] - Overwrite variable: V_VAR5 2018-01-10 20:38:26.959 [WARN ] [nal.sensors.child.MySensorsChildSHum] - Overwrite variable: V_VAR1 2018-01-10 20:38:26.980 [WARN ] [nal.sensors.child.MySensorsChildSHum] - Overwrite variable: V_VAR2 2018-01-10 20:38:26.980 [WARN ] [nal.sensors.child.MySensorsChildSHum] - Overwrite variable: V_VAR3 2018-01-10 20:38:26.980 [WARN ] [nal.sensors.child.MySensorsChildSHum] - Overwrite variable: V_VAR4 2018-01-10 20:38:26.981 [WARN ] [nal.sensors.child.MySensorsChildSHum] - Overwrite variable: V_VAR5 2018-01-10 20:38:27.084 [WARN ] [sors.child.MySensorsChildSMultimeter] - Overwrite variable: V_VAR1 2018-01-10 20:38:27.086 [WARN ] [sors.child.MySensorsChildSMultimeter] - Overwrite variable: V_VAR2 2018-01-10 20:38:27.086 [WARN ] [sors.child.MySensorsChildSMultimeter] - Overwrite variable: V_VAR3 2018-01-10 20:38:27.088 [WARN ] [sors.child.MySensorsChildSMultimeter] - Overwrite variable: V_VAR4 2018-01-10 20:38:27.089 [WARN ] [sors.child.MySensorsChildSMultimeter] - Overwrite variable: V_VAR5 2018-01-10 20:39:10.530 [WARN ] [rs.internal.gateway.MySensorsGateway] - Presented child is alredy present in gateway 2018-01-10 20:39:11.529 [WARN ] [rs.internal.gateway.MySensorsGateway] - Presented child is alredy present in gateway 2018-01-10 20:39:11.660 [WARN ] [rs.internal.gateway.MySensorsGateway] - Presented child is alredy present in gateway 2018-01-10 20:40:58.584 [WARN ] [rs.internal.gateway.MySensorsGateway] - Presented child is alredy present in gateway 2018-01-10 20:40:59.461 [WARN ] [rs.internal.gateway.MySensorsGateway] - Presented child is alredy present in gateway 2018-01-10 20:40:59.592 [WARN ] [rs.internal.gateway.MySensorsGateway] - Presented child is alredy present in gatewayWhile this is happening on MQTT:
gateway1-out/3/255/0/0/17 2.1.1 gateway1-out/3/255/3/0/6 0 gateway1-out/3/255/3/0/11 Combined Climate Sensor gateway1-out/3/255/3/0/12 1.0.16 gateway1-out/3/0/0/0/7 (null) gateway1-out/3/7/0/0/30 (null) gateway1-out/3/10/2/0/15 (null) gateway1-out/3/1/1/0/0 21.9 gateway1-out/3/0/1/0/1 42 gateway1-out/3/7/1/0/38 3.98 gateway1-out/3/255/3/0/0 56Have you got another hint for me, maybe? It would be greatly appreciated.
-
Unfortunately, I'm still making no progress here. In the meantime I deleted the MQTT Gateway in the Paper UI and restarted the device to see what would happen. Now I'm seeing an error in openhab.log:
2018-01-16 19:45:23.419 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection 'ineluki' to 'tcp://192.168.5.2:1883' with clientid openhab2 and file store '/openhab/userdata/tmp/ineluki' 2018-01-16 19:45:29.680 [INFO ] [.transport.mqtt.MqttBrokerConnection] - MQTT connection to 'ineluki' was lost: MqttException 2018-01-16 19:45:29.681 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - MQTT connection offline - {} org.eclipse.paho.client.mqttv3.MqttException: MqttException at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:176) [211:org.eclipse.paho.client.mqttv3:1.0.2] at java.lang.Thread.run(Thread.java:748) [?:?] Caused by: java.lang.NullPointerException at org.openhab.binding.mysensors.internal.protocol.mqtt.MySensorsMqttConnection$MySensorsMqttSubscriber.processMessage(MySensorsMqttConnection.java:142) ~[?:?] at org.eclipse.smarthome.io.transport.mqtt.MqttBrokerConnection$ClientCallbacks.messageArrived(MqttBrokerConnection.java:121) ~[?:?] at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:354) ~[?:?] at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:162) ~[?:?] ... 1 more 2018-01-16 19:45:29.709 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to 'ineluki' every 10000msDoes this give any clue on what's going wrong?
-
OK, n00b questions again:
- where to place the binding-jar and do I have to do something with the jar-file?
- no services directory exists in /etc. Create it?
- any other things to install? Fresh PaperUI-OpenHab installation so far.
My system:RpiZero/Scratch+Mosquitto.
-
OK, n00b questions again:
- where to place the binding-jar and do I have to do something with the jar-file?
- no services directory exists in /etc. Create it?
- any other things to install? Fresh PaperUI-OpenHab installation so far.
My system:RpiZero/Scratch+Mosquitto.
- /usr/share/openhab2/addons/
- Thank you for the hint, I've pointed to the wrong directory, it's: /etc/openhab2/services
- For additional Informations please have a look at the wiki: https://github.com/tobof/openhab2-addons/wiki
-
Ok, now I'm seeing items in my Inbox, after I changed my org.eclipse.smarthome.mqtt.cfg from
ineluki.qos=2 ineluki.retain=trueto
#ineluki.qos=2 ineluki.retain=false -
- /usr/share/openhab2/addons/
- Thank you for the hint, I've pointed to the wrong directory, it's: /etc/openhab2/services
- For additional Informations please have a look at the wiki: https://github.com/tobof/openhab2-addons/wiki
@timo I still cant find mqtt.cfg OR org.eclipse.smarthome.mqtt.cfg. I looked thru the Github stuff but didn't see it.
Any ideas where to locate either of these files? I assume they have more lines than those four on display in the example.
Thanks. Sorry I'm still a tool with OH2 -
@timo I still cant find mqtt.cfg OR org.eclipse.smarthome.mqtt.cfg. I looked thru the Github stuff but didn't see it.
Any ideas where to locate either of these files? I assume they have more lines than those four on display in the example.
Thanks. Sorry I'm still a tool with OH2@masmat As far as I know .cfg files are only the config files fpr your installed addons and are located in the service directory (see TimO's post above). And they indeed only contain the settings you want to use, which can be 4 lines only. Depends on the addon
-
@masmat As far as I know .cfg files are only the config files fpr your installed addons and are located in the service directory (see TimO's post above). And they indeed only contain the settings you want to use, which can be 4 lines only. Depends on the addon
@lastsamurai I kinda figured that. From the first post I understood that the MQTT binding (binding-mqtt1 - 1.11.0) did not need to be installed. mqtt.cfg -file does come from that. So far I haven't installed it, but if that's where the mqtt.cfg file should come from then I'll do that next.
Just dont want to have addon on top of addon if they're redundant. -
@lastsamurai I kinda figured that. From the first post I understood that the MQTT binding (binding-mqtt1 - 1.11.0) did not need to be installed. mqtt.cfg -file does come from that. So far I haven't installed it, but if that's where the mqtt.cfg file should come from then I'll do that next.
Just dont want to have addon on top of addon if they're redundant.