I’m trying to add the MQTT binding (actual version 1.9) to my new OpenHAB 2 installation.
What do I exactly have to do? The manuals are very confusing and seem to be version-dependent.
I have installed “openhab2-addons” and “openhab2-addons-legacy”, and installed Mosquitto as MQTT broker. Also I added the project into the Eclipse Smart Home Designer and edited the “/service/mqtt.cfg” and “/services/mqtt-eventbus.cfg”, set the broker name and “localhost” as server (as Mosquitto is installed on my Raspberry).
Can someone give me more information how to use MQTT 1.9 on OpenHAB2? Are there some incompatibilities with these two versions? If yes, how to use another MQTT version (my Paper UI only contains the MQTT binding and action version 1.9). Do I need also the action?
Thank you, I will try it later! So to clearify the installation steps: installing the “openhab2-addons” is not necessary but “openhab legacy addons” is? And what about the “legacy addon support” switch in the system settings in Paper UI?
We used your configuration settings and now it the MQTT broker works! Do you know the issue why I still can’t see the bindung in the Paper UI under “Configuration -> Bindings”?
A “legacy” binding is a binding that has been obsoleted by a newer binding. This is not the case for the MQTT binding. The confusion regarding 1 vs. 2 bindings should be largely resolved once this PR is merged and docs.openhab.org has been updated, which should happen hopefully very soon.
You are right, it is not legacy it is just version 1x but it will not integrate in Paper UI.
I personally prefer text configuration over GUI, especially with simple bindings that do not require some kind of auto discovery.
MQTT is a main component of IOT and I’m amazed how complicated it is made to look when it is in fact very simple to implement. Misinformation and the github entry being written by programmers for programmers doesn’t help (sorry, just my opinion).
I spent days with jar files trying to get Openhab2 to work with MQTT when in fact it is as simple as installing MQTT through PaperUi, adding the URL of the broker in the MQTT.cfg file that it creates and adding the information to the switch definition in the items files as detailed above.
I have found it easiest to make sure Mosquito is running prior to loading Openhab. If you have the prompt window open you can see it connect client xxxxx on port xxxx.
Michael, maybe I am a bit off topic, but I shy-ed away from MQTT for a long time, because it looked complicated.
Then I got to use it, in a practical example by someone who could explain very well (wich was also my first use of openhab) and I was hooked. It is really extremely simple, once you get passed the programmers talk
The demo switches are working as expected, but I don’t get it working with a rollershutter. I’m not sure, which concrete message I should send to change the percent value of the rollershutter.
Cheers!
Christian
UPDATE: Solved! See my solution in other thread (url above)
look, i love the promise of openHAB2 but im having the worst experience ever so far.
keep it simple right? this is what i was thinking when i decided to download the latest stable openhabian image… after the 4th try it still gave me errors that i could not sort(im no programmer)out.
3 more tries with the netInst version and i was away…
when i eventually got the thing to work(stable heartbeat with the leds),
i got a bit excited,but now im just frustrated.
i cannot get MQTT to work.
installed mosquitto on the pi3, it works, i can connect to it with devices etc.
can NOT get openhab2 to talk to the broker.
mqtt.cfg file
mqtt:mosquitto.url=tcp://localhost:1883
mqtt:mosquitto.clientId=openhab
mqtt:mosquitto.retain=true
mqtt:mosquitto.async=false
any help would be greatly appreciated as ive been at this for a week now and cannot get it to work.
i am probably overlooking something, and yes its gotten a little messy there…but for a start im just trying to get it to publish ANYTHING to the broker.
thanks for your Reply Dim, i seem to have got it working , more luck than good management…lol, but im still having some small issues so im going to to follow your suggestions, but how do i stop OH2 in openhabian?
19:24:19.445 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Unable to connect to server (32103) - java.net.ConnectException: Connection refused
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:75)[217:org.openhab.io.transport.mqtt:1.9.0]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:538)[217:org.openhab.io.transport.mqtt:1.9.0]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.8.0_65]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)[:1.8.0_65]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)[:1.8.0_65]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)[:1.8.0_65]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.8.0_65]
at java.net.Socket.connect(Socket.java:589)[:1.8.0_65]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:66)[217:org.openhab.io.transport.mqtt:1.9.0]
... 2 more
I have other MQTT clients connected with the same credentials.
Which MQTT protocol version is used in the binding?