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:
[org.openhab.io.transport.mqtt ] - ServiceEvent REGISTERED - {org.openhab.io.transport.mqtt.MqttService, org.osgi.service.cm.ManagedService}={service.pid=org.openhab.mqtt, component.name=MQTT Connection Service, component.id=1, service.id=279, service.bundleid=164, service.scope=bundle} - org.openhab.io.transport.mqtt [org.openhab.io.transport.mqtt ] - BundleEvent STARTING - org.openhab.io.transport.mqtt [org.openhab.io.transport.mqtt ] - BundleEvent STARTED - org.openhab.io.transport.mqtt [penhab.io.transport.mqtt.MqttService] - 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}={component.name=org.openhab.binding.mqtt.genericbindingprovider, component.id=167, service.id=292, service.bundleid=163, service.scope=bundle} - org.openhab.binding.mqtt [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=168, service.id=294, 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/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=169, service.id=295, 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):
mosquitto.url=tcp://localhost:1883

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.

Thanks
Christian

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

Result:
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.
Christian

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

mosquito.url=tcp://192.168.2.15:1883
mosquitto.clientId=openHAB
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?

thanx,
Frank

One ‘t’ is missing.

Then some inconsistency in the topics:
home/alarm/flashlight
openhab/home/alarm/flashlight

and extra symbol before 0:

command:OFF:`0

Andrew,
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
mqtt.cfg:
mosquitto.clientId = openHAB mosquitto.url = tcp://192.168.1.6:1883 service.pid = 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:
publisch:
openhab/home/alarm/flashlight OFF
openhab/home/alarm/sensor 22

Subscribe:
openhab/home/alarm/flashlight

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.

thanx
Frank

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.

Frank