and get the following response on topic ‘stat/FrontLoungeMedia/POWER’, the message OFF.
Also, the device does what it is told.
I can use MQTTLens to subscribe to all topics (topic #), but don’t see any communication between openHAB and MQTT no matter what I do.
The file /var/log/openhab2/events.log on the RPi does not include any mention of MQTT messages.
The file /var/log/openhab2/openhab.log includes the following error:
2017-04-21 13:18:21.344 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT c$
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsRecei$
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_12$
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqt$
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsRecei$
Plea for help
So I am lost and confused, not sure what needs to be done from here, pretty confident that I have misinterpreted the instructions somewhere. Suggestions appreciated.
I appreciate the effort. If you read https://community.openhab.org/users/KjetilA 's comment, it appears that there is an error in the information you provided - perhaps from older iterations of OpenHAB?
I did the following:
Replaced<broker> with mqtt:mqtt-loc.url in the mqtt.conf file.
Edit the items file and within that change the MQTT command to reflect those changes.
I chose not to change the IP address.
So we got one win in /var/log/events.log:
1493359108: mosquitto version 1.4.11 (build date Mon, 20 Feb 2017 22:47:27 +000$
1493359108: Config loaded from /etc/mosquitto/mosquitto.conf.
1493359108: Opening ipv4 listen socket on port 1883.
1493359108: Opening ipv4 listen socket on port 1883.
1493359110: New connection from 192.168.1.200 on port 1883.
1493359110: New client connected from 192.168.1.200 as lens_GcWKQNQMAeqRxTomkPR$
1493359150: New connection from 127.0.0.1 on port 1883.
1493359150: New client connected from 127.0.0.1 as openhab2 (c1, k60).
1493359150: New connection from 192.168.1.201 on port 1883.
1493359150: Client openhab2 already connected, closing old connection.
1493359150: Client openhab2 disconnected.
1493359150: New client connected from 192.168.1.201 as openhab2 (c1, k60).
1493359160: New connection from 127.0.0.1 on port 1883.
1493359160: Client openhab2 already connected, closing old connection.
1493359160: Client openhab2 disconnected.
1493359160: New client connected from 127.0.0.1 as openhab2 (c1, k60).
1493359170: New connection from 192.168.1.201 on port 1883.
But still nothing showing up on MQTTLens and no action from the configured switch.
Delete /var/lib/openhab2/config/org/openhab/mqtt.config and restart OH2 with the correct /etc/openhab2/services/mqtt.cfg in place (possible stale configs have been saved in the mqtt.config and this is causing troubles)
Here is a working example of a mqtt.cfg file. Use this to customize it to your system. Don’t use mqtt: in front of the broker name.
# URL to the MQTT broker
HomeR.url=tcp://localhost:1883
# Client id to use when connecting to the broker.
HomeR.clientId=openhab2
Make sure that the clientId is unique (don’t use the same Id for your Sonoff)
If you use authentication on your Mosquitto, set also the user and pwd settings within the /etc/openhab2/services/mqtt.cfg
There was indeed an mqtt.config file in /var/lib/openhab2/config/org/openhab.
In addition, there was addons.config, dashboard.config, habpanel.config and ui folder.
I have deleted the mqtt.config file. Should I delete the others as well?
The Sonoff has a separate clientID (DVES_%06X) which I think is the default in the Tasmota firmware.
So having followed Dim and Kjetil’s advice, I can now see a huge number of Java errors where it appears OpenHAB is trying to contact org.eclipse.jetty and org.glassfish.jersey for dozens of different reasons, but there is still no evidence of communication with MQTT.
No!
These (*.config) files are generated by OH2 processes and they are like the internal version of the configs in the files that you place in the /etc/openhab2/services/ directory. Normally, you shouldn’t change anything there but sometimes, if you make some wrong configs in *.cfg they remain in *.config.
Did you enable debug? No sign of MQTT stuff there?
Many thanks for the ongoing support. I finally worked out a way to test this (slow, I know):
I turned Mosquito off using sudo systemctl stop mosquitto
I got a lot of complaints in the openhab log file which I was monitoring in a separate terminal window using your suggested command (tail -f /var/log/openhab2/openhab.log):
2017-04-30 11:34:20.264 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost Connection lost (32109) – java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)[199:org.openhab.io.transport.mqtt:1.9.0] at java.lang.Thread.run(Thread.java:748)[:1.8.0_131] at java.lang.Thread.run(Thread.java:748)[:1.8.0_131] Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_131] at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56)[199:org.openhab.io.transport.mqtt:1.9.0] at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100)[199:org.openhab.io.transport.mqtt:1.9.0]
Then I turned it back on.
I saw:
2017-04-30 11:43:30.325 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker 'mqtt-loc' on topic 'stat/FrontLoungeMedia/POWER'
(Which is a status message from a Sonoff device on my network)
Hence I conclude that the binding is working.
Many thanks for your help gentlemen. I hope my longwinded responses help some other poor soul who has managed to overthink everything : )
I am fresh from battling this issue on a Raspberry Pi using OpenHabian. I can’t help on other platforms as I am a complete noob, but perhaps I can offer some sort of help if that is what you need.