[SOLVED] How to add a MQTT Thing

Hi everyone, I am a newbie in OpenHAB, and I have something don’t understand when I want to add a MQTT Thing

  1. Following this, there are 6 steps to add a Thing to OpenHAB, and step 3 is add Thing and configure. And I can configure by add a .things file with syntax: Thing <binding_id>:<type_id>:<thing_id> “Label” @ “Location” [ ]. But I wondering, with MQTT what are binding_id, type_id, thing_id? Can you write a example for me?

  2. When I read this to add a MQTT Thing, I add a file services/mqtt.cfg with content: “m2m-eclipse.url=tcp://m2m.eclipse.org:1883” and then I add and configure files in items folder and sitemap folder. But according this, I just add a Item not a Thing? I’m wondering about this? Can somebody explain for me? Or OpenHAB do not support add MQTT Things?

Thank you very much!!!

1 Like

you don’t need a thing for mqtt
MQTT Binding

But I think everything that OpenHAB control should be a Thing and inside a Thing, you can have some Items and Channels?

just add the binding and link the channel to the item. Examples are in the link above.

So it’s a Item not a Thing?

Everything links to an item eventually.

Add an item to your items file with the channel for mqtt. Then add it to your sitemap.

Not sure if you can set it up through paperui, I’ve never tried.


The binding name and version tell me its a legacy binding. Only version 2 or above will ever support a thing and some of them don’t either as there isn’t a need for them always.

binding-mqtt1 - 1.12.0.SNAPSHOT

Yeah. I did it and it’s work. But it’s not show in PaperUI so I thing I have to add it’s as a Thing. So now it’s clear. Thank you very much :+1:

This was helpful…just configured the item for MQTT binding and connected to my ESP8266…things are working fine…

Hi all

I have SONOFF devices, which I can contact and command by items I created.
Now as I have alot of those devices in my house, I want to combine all the different capabilities of a device into a THING. I am aware that a THING is not needed for MQTT, but I want to have for all my devices that really excist a THING defined.

Can somebody tell me, how the THING declaration must look for a MQTT device?
My aim is to have in the paper UI under things all physical devices and that I can go look there what channels (capabilities), each of the devices has.

This I want to write into the sonoff.things, but I have no clue, what to write into the binding part…

Thing mqtt:device:heizung "Heizung" @ "Keller" [ ????, ?????, ... ]

PLEASE HELP? And yes I know that things are not needed, but I want a proper structure and want to see under things in the paper UI all my physical devices.

The MQTT binding is a 1.9x version binding that is compatible with the 2.x openHAB
Unfortunately the MQTT binding doesn’t support things. I don’t think you will be able to achieve that.

There will be a 2.x version of the MQTT binding eventually. This will support things.

Many thanks for the fast response. Now I understand, why I failed for so long, as this binding is simply not supporting any things.

So I will stick to group items in my sonoff.items file and hope and wait for an update.

This is the reason why mqtt bindings can only be made to text defined items
By the way, the answer was already there in Post#7

Hi @lobocobra , it goes like this, with reference from this link

Item myItem {mqtt="<direction>[<broker>:<topic>:<type>:<transformer>:<regex_filter>], <direction>[<broker>:<topic>:<type>:<transformation>], ..."}

In your case this should be ( for incoming messages to openhab)

Switch doorbell "bell [%s]" {mqtt="<[brokername:myHome/doorbell:state:default]}

For sending command to your device, you need to define an item

Switch doorbell "bell [%s]" {mqtt=">[mybroker:myhouse/office/light:command:ON:1],>[mybroker:myhouse/office/light:command:OFF:0]"}

You will have to combine both statements to have one item definition.

Thanks digicos for the response.

But the items themself I have working since a year. So that is not an issue. I tried to combine/group MQTT into THINGS, which is not working due to the fact that 1.9 bindings do not support THINGS (as simple as that).

Another idea of me was now to integrate the MQTT SONOFF devices in the CCU2 (then I would have things), but the MQTT support is so poor and the community behind is like 1 developper, that I dropped that idea. Also the useage of HTML binding makes no sense for me. (delay/NW traffic).
=> Let’s see what happens first… an updated MQTT Binding or another way (MQTT to xxx converter)
=> Meanwhile I group my “channels items” in an item file

My question was already answered here, thanks to you all.

You can use node-red for that

Cool! I did not know that tool. :slight_smile:
=> Node-red seems to be much more and I did not know it, I gonna use that for sure.