MQTT Help, just cant get it working

I know this is going to be yet another noob reaching out for help thread… But I have spent over 24hrs trying everything to get MQTT working in openhab.

So to confirm the situation, all running on a Raspberry Pi (Whizzy)

  1. Openhab installed and running ok
  2. Mosquitto installed and running ok (two terminal SUB/PUB messages working.
  3. Copied “org.openhab.io.transport.mqtt-1.7.0.jar” into “addons” folder.
  4. Checked /tmp/broker/ folder and there are additional folders for the clientid

But i just cant get openhab to publish a MQTT message.

openhab.cfg

mqtt:broker.url=tcp://localhost:1883
mqtt:broker.clientId=openHab

Items

Switch LightLoungeMain2 “Main Light2” icon=“light” {mqtt=">[broker:/GF/LoungeMain:command:ON:1]"}


I have tried a restart of the mosquitto service whilst tailing the log file and can see openhab detecting the lost connection and then reconnecting ok.

With logging on DEBUG i get this on the start up

2015-10-10 09:13:54.708 [DEBUG] [.io.transport.mqtt.MqttService] - Starting MQTT Service…
2015-10-10 09:13:54.804 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2015-10-10 09:13:54.818 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection ‘broker’
2015-10-10 09:13:54.878 [DEBUG] [o.i.t.m.i.MqttBrokerConnection] - Creating new client for ‘tcp://localhost:1883’ using id ‘openHab’ and file store ‘/tmp/broker’

But now im stuck!

Any help would be much appreciated… (very much appreciated!!)

Update

I have removed the addin jar ver 1.7.0 and installed the mqtt addin via apt-get.

I can now publish a MQTT message via terminal and openhab receives the subscribed value and updates an MQTT item.

But still cant seem to have openhab publish a MQTT on a switch state change.

working item

String mqttMessage “MQTT [%s]” { mqtt="<[broker:/GF/LoungeMain:state:default]" }

Still not working

Switch LightLoungeMain2 “Main Light2” icon=“light” {mqtt=">[broker:/GF/LoungeMain:command:ON:1],[broker:/GF/LoungeMain:command:OFF:0]"}

I am noticing this in the DEBUG, which I wonder is something to do with it???

Debug message

2015-10-10 10:26:48.779 [DEBUG] [o.o.i.r.i.b.GeneralBroadcaster] - broadcaster ‘org.openhab.io.rest.internal.broadcaster.GeneralBroadcaster$1@155205e’ is empty

Further update.

I am now thinking this must be a syntax or config error on the items.

I have set up the following broker and eventbus.


mqtt:uhura.url=tcp://localhost:1883

mqtt-eventbus:broker=uhura
mqtt-eventbus:commandPublishTopic=home/out/${item}/command
mqtt-eventbus:statePublishTopic=home/state/${item}/state


This is working correctly and now the Mosquitto_sub terminal is displaying events.

I still cant publish a specific MQTT message using the ITEM …

Can anyone see a problem with this from my item file?

Switch mqttTestSwitch “MQTT Test” icon=“light” {mqtt=">[uhura:/GF/Test:command:ON:ON],>[uhura:/GF/Test:command:OFF:OFF]"}

[quote=“Andrew_Brown, post:3, topic:3208, full:true”]
Can anyone see a problem with this from my item file?[/quote]

Yes, change

Switch	mqttTestSwitch "MQTT Test" icon="light" {mqtt=">[uhura:/GF/Test:command:ON:ON],>[uhura:/GF/Test:command:OFF:OFF]"}

to

Switch	mqttTestSwitch "MQTT Test" <light> {mqtt=">[uhura:/GF/Test:command:ON:ON],>[uhura:/GF/Test:command:OFF:OFF]"}
1 Like

Sihui.

Cant thank you enough, moving to a new syntax its always difficult to see an obvious mistake!

Making that change has fixed the issues and MQTT messages being sent!!

On with the planning and build of a full automated house !