[SOLVED] MQTT not sending command in OH2?


(D) #1

Hi there,

I’ve managed to get mqtt up and running again after migrating from 1.8. Problem is that the message doesn’t seem to be sending when I flick a Switch from ON/OFF and vice versa.

If I use mosquitto_pub manually with the following it works!
mosquitto_pub -t ‘ninjaCape/output/11’ -m ‘101001100011100100000010’

but the following item doesn’t seem to work?

Switch K_Light “Kitchen Lights”
{mqtt=">[mosquitto:ninjaCape/output/11:command:OFF:101001100011100100000010],>[mosquitto:ninjaCape/output/11:command:ON:101001100011100100001010]"
}


(Andrew) #2

Please check what is in the log and make sure that “mosquitto” is properly defined in mqtt.cfg
And please fix formatting error in your post - note > symbol in the binding configuration.


(D) #3

Thanks. Fixed the format. Mqtt.cfg has mosquitto.url=tcp://localhost:1883

I assume that’s correct?


(Andrew) #4

That’s correct and the rest looks good for me. I’m wandering what is in the log.


(D) #5

Thanks for checking. Which log would that be? openhab.log has no errors relating to this. What I did notice is that my when I boot openhab, the original client name “oh2” still appears before mosquitto which is what I changed it to… Could this be a problem?

The null issue is just a mapping error…

2017-01-29 02:08:22.671 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'oh2.items’
2017-01-29 02:08:53.860 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'OH2.sitemap’
2017-01-29 02:09:14.195 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at /start
2017-01-29 02:09:21.234 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-01-29 02:09:21.265 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto’
2017-01-29 02:09:24.572 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'oh2’
2017-01-29 02:09:31.962 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2017-01-29 02:09:36.008 [INFO ] [assic.internal.servlet.WebAppServlet] - Started Classic UI at /classicui/app
2017-01-29 02:09:40.228 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2017-01-29 02:09:44.429 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2017-01-29 02:09:45.971 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel2017-01-29 02:10:41.965 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘NULL’ with the file ‘open.map’ : Target value not found in map for 'NULL’
2017-01-29 02:10:41.976 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘NULL’ with the file ‘open.map’ : Target value not found in map for 'NULL’
2017-01-29 02:10:46.435 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘NULL’ with the file ‘open.map’ : Target value not found in map for ‘NULL’


(Andrew) #6

You seems to have 2 connections defined. I suggest to remove 1 to avoid confusion. Then you could probably enable debug for mqtt and check what’s going on there when you sliding the switch.


(Rich Koshak) #7

Look in userdata/config/org/openhab/mqtt.config. There is a bug where removing fields from a cfg file so not get removed from that file which can cause problems.

For apt-get userdata is in /var/lib/openhab2


(D) #8

Thanks - that worked to remove the unused oh2 mqtt, unfortunately doesn’t resolve my problem.

How do I enable / check mqtt logs? Do I need to do it through karaf?

From what I read, I need to enable more detailed logging for the mqtt binding. I’m getting this though - seems I can’t login to the karaf console?

[10:18:09] pi@openHABianPi:~$ ssh openhab@localhost -p 8101
Received disconnect from 127.0.0.1: 2: Session has timed out waiting for authentication after 120000 ms.

Edit: Nevermind - just made it in - had some time…

Sorry, bear with me:
I put this in:

log:set DEBUG org.openhab.binding.mqtt

but the logs show nothing when i flick the switch in my browser in either log:tail or openhab.log. I know there’s something going on in mqtt because I have two of my doors sending messages through an ESP8266 via MQTT and it’s registering the correct switches


(Rich Koshak) #9

That is what it looked like when I had the problem with the MQTT action preventing my MQTT binding from working.


(D) #10

Anyone got any ideas? Or how I go about debugging this? I’m out of ideas here… Thinking of using exec binding to run the mosquitto_pub command


(D) #11

update for everyone.

Here’s where I went wrong. I was using HABMIN UI to control my switches which actually wasn’t doing anything at all!

Not sure what’s going on with that. I changed ClassicUI to my sitemap and used that instead and everything’s working now.

Resolved. Thanks all.


(Szabi) #12

Hi there!

I know that it is an old post but it may be related to my issue that I can’t get rid from error messages caused by old, unused broker like mqtt1, mqtt_test etc…

I cleaned my mqtt.conf file but errors are still there.

My config file:
MQTT.url=tcp://localhost:1883
MQTT.clientId=openhab
MQTT.user=test
MQTT.pwd=test

Log:
07:18:12.383 [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:146)[198:org.openhab.io.transport.mqtt:1.10.0]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_144]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_144]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[198:org.openhab.io.transport.mqtt:1.10.0]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[198:org.openhab.io.transport.mqtt:1.10.0]
… 1 more
07:18:12.391 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘mqtt1’ was lost: Connection lost : ReasonCode 32109 : Cause : null

I know from your post that it is a bug but is there any solution to remove the unused brokers?

Thanks!


(Angelos) #13

(Szabi) #14

Thanks, this solved all the problems!