MQTT Setup Check

Hey all, I’m just messing with MQTT and having a bit of trouble (been searching the forums like mad and trying everything I can).

I have this in the logs:
[ ] - ServiceEvent REGISTERED - {,}={, Connection Service,,, service.bundleid=164, service.scope=bundle} - [ ] - BundleEvent STARTING - [ ] - BundleEvent STARTED - [] - Starting MQTT Service... [t.mqtt.internal.MqttBrokerConnection] - Creating new client for 'tcp://localhost:1883' using id '***' and file store '/opt/openhab/userdata/tmp/mosquitto' [org.openhab.binding.mqtt ] - BundleEvent STARTING - org.openhab.binding.mqtt [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started. [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={,,, service.bundleid=163, service.scope=bundle} - org.openhab.binding.mqtt [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler,}={event.topics=openhab/*,,,,, service.bundleid=163, service.scope=bundle} - org.openhab.binding.mqtt [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding. [ng.mqtt.internal.MqttEventBusBinding] - Initializing MQTT Event Bus Binding [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus State Publisher for topic home [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/*,,,, service.bundleid=163, service.scope=bundle} - org.openhab.binding.mqtt [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus State Subscriber for topic home [org.openhab.binding.mqtt ] - BundleEvent STARTED - org.openhab.binding.mqtt [ng.mqtt.internal.MqttEventBusBinding] - MQTT Event Bus Binding initialization completed. [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'test' : 0 subscribers, 1 publishers

I don’t know where it’s getting the topic for ‘home’ from as I haven’t got it set anywhere (although when testing I did).

Here’s my mqtt.conf (mqtt-eventbus.cfg is all commented out):

And this is one of the many items I’ve tried:
String test {mqtt=">[mosquitto:openhab/notification/info:state:*:default]"}

Basically all I’m after is to be able to publish from another client (MQTT.fx on OSX) and see an item update and visa versa, when an item updates the subscription on my other client will update.

Any help would be much appreciated, I’ve gone round in circles a bit here, did have updates coming through in the log, but no longer do.


The example you have provided would be an outbound MQTT item. How are you triggering the MQTT publish from OpenHAB2? Is it through a sitemap or a rule? Could you provide the example of how that’s setup?

It might make sense to try and sort out an inbound connection first. Perhaps try defining that item, publishing from another client, and providing the log output.

I’m using the MQTT binding under OpenHAB2 and it’s working great for me, so I think we should be able to help you getting working.

Hi, thanks for lending a hand. I’ve tried inbound as well, but I’ll have another pop at it tonight and let you know the results. Ohh also I’m sending outbound from a sitemap, maybe that’s not going to send the message I think it is.

And today it is working. Go figure!
For anyone else struggling Here’s my item:
Number test "MyNumber [%.1f %%]" {mqtt="<[mosquitto:openhab/home/test:state:default]"}

And not surprisingly sending this from mqtt.fx:
openhab/home/test 33

22:18:04.759 [INFO ] [marthome.event.ItemStateChangedEvent] - test changed from 10 to 33

Must have been tired yesterday :slight_smile:
Thanks for lending a hand though.

Hi Cristian,
I am also struggeling with mqtt and openhab2, I do not get messages published or subsribed.
These are my settings:

there is left commented out.

items file:
Switch alarmFlashL { mqtt=">[mosquitto:home/alarm/flashlight:command:ON:1],>[mosquitto:openhab/home/alarm/flashlight:command:OFF:`0]" }

Number temperature “tNumber temperature temp [%.1f °C]” {mqtt="<[mosquitto:openhab/home/alarm/sensor:state:default]"}

sitemap file:
Frame label= “Alarm”{
Switch item=alarmFlashL
Text item=temperature
Things has noting in it for mqtt
Do you know what I am missing or doing wrong?


One ‘t’ is missing.

Then some inconsistency in the topics:

and extra symbol before 0:


thanks allot I did not see those typos my self, thanks to you I could solve them.
But stil it dus not work :frowning:

stetting are now
mosquitto.clientId = openHAB mosquitto.url = tcp:// = org.openhab.mqtt

items file:
Switch alarmFlashL { mqtt=">[mosquitto:openhab/home/alarm/flashlight:command:ON:1],>[mosquitto:openhab/home/alarm/flashlight:command:OFF:0]" }
Number temperature "tNumber temperature temp [%.1f °C]" {mqtt="<[mosquitto:openhab/home/alarm/sensor:state:default]"}

sitemap file
Frame label= "Alarm"{ Switch item=Burglar_alarm Switch item=alarmFlashL Text item=temperature }

I use mqtt.fx to publish an subscribe:
openhab/home/alarm/flashlight OFF
openhab/home/alarm/sensor 22


I still do not see anything in the events.log of openhab.
I know that Mosquitto works because can receive the message (publisched with mqtt.fx) in mqff.fx and on an arduino.
Does anybody see what I do wrong?

For testing I would subscribe to # and see on what topic your sensors are coming in:

Then use EXACTLY the shown topic (in my case /esp8266four/temperature/shadow) for your items.

Number TemperatureShadow "Temperatur [%.1f °C]" (gInfluxdb) { mqtt="<[mosquitto:/esp8266four/temperature/shadow:state:default]" }

Sihui thanks for for you response this will help me in the next stadium.
but first I have this problem is: when I installed the mqtt binding with paper UI mqtt communication works.
but when I restart my raspberry pi the mqtt installation is gone and it does not work anymore.

What should I put in the in the addons.cfg:

A comma-separated list of bindings to install (e.g. “sonos,knx,zwave”)`

binding = chromecast,max,mqtt

or should I add it at the Action label.


MQTT is a 1.9 binding, so it needs to be:
binding = chromecast,max,mqtt1

Thanx Sihui that will help, I will try it tonight, together with the “#” tip.