[SOLVED] Mqtt in openHab2 -

Hello All:

I’m trying to test mqtt in openhab2, but so far I can’t make it work!

I have a switch defined as follows in demo.items;
Switch mySwitch “Office Light” {mqtt=">[mqtt:broker:myBroker:/office/light:command:ON:1],>[mqtt:broker:myBroker:/office/light:command:OFF:0]"}

So I would like to receive notifications when this switch changes. For this, I’m using MQTT.fx client and subscribed to /office/light topic.

In installed the following Add-ons using Paper UI;

  • Embedded MQTT Broker
  • MQTT Binding (2.4.0)

I can connect to the broker from the MQTT.fx client, but not receiving any subscription… My main doubt is in the mqtt binding setting so not sure if the string “mqtt:broker:myBroker” is this the right one. At least, this is what appears in Things -> MQTT Broker (ONLINE).

To me, mqtt support is a little bit confusing as looking online, there are multiple threads talking about configurations which seems to be for different versions (1.x binding) or using the mqtt.cfg file, which I read it’s not longer necessary if using Paper UI configuration.

All in all, it seems the embedded broker is working (I can test it with MQTT.fx client) but the opnhab connection to the broker is not, or at least, I’m not using the right setting in the binding portion of the item description.

I would appreciate any help.


You are using the old item syntax. We just recently swapped out the old mqtt1 binding with a new one. A lot of examples you find on the internet will show you what you’ve got. But please read the documentation pages of the mqtt2 binding a bit more closely :slight_smile:

Cheers, David

Thanks, David:

I followed the examples in

and added the bridge, items and rules, but I get following error:

Is something else I have to configure?


These are the things I have;

BTW, I 'm receiving mqtt messages from topic “system/started” (payload: true) so mqtt is working…


The “No mqtt client” ertor sounds like the known bug of the new binding. Did you do changes on the .things file?
A restart should solve that problem.

Yes, now it’s working.
However, I would like to better understand the syntax used to define the channels in the full example provided in the documentation;

There is documentation for items and things definition, but so far I couldn’t get anything aboout how to define the channels. Is there any help on how the above syntax is defined?


IMHO the link for the documentation you posted above has it all. If you have further questions please post them in a new thread.

My question is, why are you not using the paperUI to create your things?

I want to control it from my app, not from a console…

One has nothing to do with the other. It works the same. It’s just easier and safer to use the paperUI to create things and channels than text files