I’m trying to get a LED on a LED on my ESP8266 with MQTT on my raspberry pi with OH2.2.0. I installed it with apt-get and configured it in the shell. On the ESP there’s a program which turns the LED on when the MQTT gets
mosquitto_pub -t "/test/light1" -m „1“
or to turn off mosquitto_pub -t "/test/light1" -m "0"
in the shell. This works.
Now, I’d like to implement the control to Openhab. I installed the MQTT Binding in PaperUI. What I’ve tried:
OH2MQTT.url.url="tcp://xxx.xxx.x.xxx:1883" (x replaced by my ip)
broker.url="tcp://xxx.xxx.x.xxx:1883" (x replaced by my ip)
mosquitto.clientId="openHAB2"
mosquitto.pwd="***********" (* replaced by my pw)
mosquitto.url="\=tcp://xxx.xxx.x.xxx:1883" (x replaced by my ip)
mosquitto.user="domeninini"
service.pid="org.openhab.mqtt"
With the command ON in the sitemap you can do this:
openhabian@pi:~$ mosquitto_pub -t “/test/light1” -m "1"
and with the command ON you can control this:
openhabian@pi:~$ mosquitto_pub -t “/test/light1” -m “0”
When the mqtt.cfg is changed the connection is restarted but i assume not with the changed value.
When i enter a wrong brocker address i get the errror when restarting. When i change the broker url the error comes againb besides that it is correct then.
The /var/lib/openhab2/config/org/openhab/mqtt.config gets updated.
And it is not very helpfull, maybe extending the massage to report what client, port, topic, etc was used would help track down such problems.
20:52:37.456 [INFO ] [rt.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mymosquitto'
20:52:37.482 [ERROR] [openhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: MqttException
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38) [205:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664) [205:org.openhab.io.transport.mqtt:1.11.0]
at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.net.UnknownHostException: Nolocalhost
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
at java.net.Socket.connect(Socket.java:589) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) ~[?:?]
... 1 more
@kai as always i don´t know where to place this issue, openhab1-addons, openhab2-addons, smarthome?
Hey there, I am migrating to my new raspi 4 and I have a similar problem.
Mosquitto is working in the shell, but nothing happens, when toggling a switch in BasicUI. The output of “cat /etc/openhab2/services/mqtt.cfg” is:
It think you are right ! On my old pi, I used the .cfg file and no things file. This works find and I don’t see a reason why to upgrade to v2. (What would be the advantage ? )
So, I’d like to use the old v1. Now, I activated the Include 1.x Bindings Legacy and installed the the v1 Binding and see there - it works ! Thank you ! I did not realised that there is a new version.