Need help to migrate to the mqtt binding v2 in openhab 2.4


i have no plan how to add the mqtt items from openhab 2.3 to openhab 2.4

Switch Light_GF_Living 	"Wohnzimmer" <light> (GF_Living, Lights, Lampe) {mqtt=">[mosquitto:cmnd/Sonoff_Touch_Wohnzimmer/POWER2:command:*:default],<[mosquitto:stat/Sonoff_Touch_Wohnzimmer/POWER2:state:default]"}
Switch Light_GF_Living_Wall "Wand" <light> (GF_Living, Lights, Lampe) {mqtt=">[mosquitto:cmnd/BeleuchtungWandWohnzimmer/POWER:command:*:default],<[mosquitto:stat/BeleuchtungWandWohnzimmer/POWER:state:default]"}
Dimmer RGBW_GF_Living_Wall "Licht Dimmen"	(GF_Living, Lights)	{mqtt=">[mosquitto:cmnd/BeleuchtungWandWohnzimmer/Dimmer:command:*:default],<[mosquitto:stat/BeleuchtungWandWohnzimmer/Dimmer:state:default]"}
Color Color_GF_Living_Wall	"Licht Farbe"	(GF_Living, Lights)	{mqtt=">[mosquitto:cmnd/BeleuchtungWandWohnzimmer/HsbColor:command:*:default],<[mosquitto:stat/BeleuchtungWandWohnzimmer/HsbColor:state:default]"}
String Scheme_GF_Living_Wall "LED Scheme"	<sofa> {mqtt=">[mosquitto:cmnd/BeleuchtungWandWohnzimmer/Color:command:1:FFFFFF],>[mosquitto:cmnd/BeleuchtungWandWohnzimmer/Scheme:command:2:9],>[mosquitto:cmnd/BeleuchtungWandWohnzimmer/Scheme:command:3:3],>[mosquitto:cmnd/BeleuchtungWandWohnzimmer/Scheme:command:4:11]"}
Color Light_Garage_Wall_Color  "Wand Garage Farbe" (Garden)	 {mqtt=">[mosquitto:cmnd/MagicHome_LED_Garage_Wand/HsbColor:command:*:default],<[mosquitto:stat/MagicHome_LED_Garage_Wand/RESULT:state:JSONPATH($.Color)]"}
Switch Tradfri_GU10_Gaestezimmer_Spot_1  "Spot Gästezimmer 1" <light> (Lights, Lampe, Spot_Gaestezimmer) {mqtt=">[mosquitto:zigbee2mqtt/Tradfri_GU10_Gaestezimmer_Spot_1/set:command:*:MAP(],<[mosquitto:zigbee2mqtt/Tradfri_GU10_Gaestezimmer_Spot_1:state:JSONPATH($.state)]"}
Dimmer Tradfri_GU10_Gaestezimmer_Spot_1_Dimmen  "Spot Gästezimmer 1 Dimmen" <light> (Spot_Gaestezimmer)   {mqtt=">[mosquitto:zigbee2mqtt/Tradfri_GU10_Gaestezimmer_Spot_1/set:command:*:JS(setZigbeeBrightness.js)],<[mosquitto:zigbee2mqtt/Tradfri_GU10_Gaestezimmer_Spot_1:state:JS(getZigbeeBrightness.js)]"}
Rollershutter Rollershutter_GF_Living_1   "Wohnzimmer Links" <rollershutter>	(GF_Living, Shutterswz) { mqtt=">[mosquitto:cmnd/sonoffrf/Backlog:command:up:RfSync 11310; RfLow 360; RfHigh 1050; RfCode #000015],>[mosquitto:cmnd/sonoffrf/Backlog:command:down:RfSync 11310; RfLow 360; RfHigh 1060; RfCode #000014]" }
Number Temperature_FF_Bed_Batterie	"Temperatursensor Schlafzimmer"	<battery>	(Batterie)	{mqtt="<[mosquitto:zigbee2mqtt/Xiaomi_temperature_&_humidity_FF_Bed:state:JSONPATH($.battery)]"}

this are some different items from my config in openhab 2.3

the mqtt broker is online:

Bridge mqtt:broker:mosquitto [ host="", secure=false ]

how do i need to write the thing in the things file to get the items working?

it would be nice when someone can help me.

  • Platform information:
    • Hardware: Raspberry Pi 3B+
    • OS: raspbian stretch (openhabianpi)
    • openHAB version: 2.4
  • Issue of the topic: need help to migrate to the mqtt binding v2
1 Like

Please first try yourself with the documentation of the binding (the mqtt generic document linked at the head of the mqtt document).

You need one thing and a channel each for each item.

The zigbee2mqtt items will not work with the new 2.x binding because of:

  • outgoing transformation
  • Javascript transformation

You need to install the 1.x mqtt binding additionally in order to get them working again.

1 Like

thank you for this information!

i will install the good old mqtt v1 binding :slight_smile:

1 Like

I tried the new one and didn’t like it too much.
I went back to the old as thats where all my setup is.

1 Like

the most items are mqtt items in my setup, for me it will be also the best solution

I have been struggling for 2 days after upgrading from OpenHAB 2.1 to 2.4, but gave up the migration towards the new MQTT binding. I also use JSON transformations, so I will stick with the old mqtt 1.3 binding until there’s a more stable version (and hoping for better documentation on the JSON specifics)

1 Like

The mqtt2 binding is actually way more stable than mqtt1. Automatic test suits, newer paho library, asynchronous receiving and sending. But it is fully building on OH 2 concepts. And if you have avoided to learn the new concepts so far (probably because you have migrated from OH 1), it will be difficult to understand why the new binding does things more “complicated”.

The same problem here. At the moment it isn’t as flexible as the good old one in my eyes. For my dimmer it is neccesary to transform a value form 0-100 to 0-255 before publishing (subscribing the other direction). With the old one I can use a scale for it


, but with the new binding I have no idea how to solve this problem.
Because the doc says: “The channel will publish a value between 0 and 100”

1 Like

That’s not true. I got it working. Can’t show my config because I’m restructuring every MQTT-Things right now to thing-file-based config. Basically I followed these instructions:

I entered the Javascript transformation as a single line into PaperUI. It worked.

As soon as have my file based config running. I’ll let you know…


After some work I got it running again …

I am controlling some Osram plugs with the help of Zigbee2MQTT. Today I migrated the first 2 plugs to the new MQTT binding:

Thing topic osram_plug_01 {
	Type switch : plug "Tolomeo Sofa" [
		on="ON", off="OFF" ]
Thing topic osram_plug_02 {
	Type switch : plug "Parentesi Sofa" [
		on="ON", off="OFF" ]

Currently working on a Osram RGB bulb …


Any news related to the Osram RGB bulb?

I also tried it and had some problems - I found out that the “outgoing transformations” feature is coming in version 2.5 which will definitely help in make this work again.

1 Like

Yes, that’s were I am stuck, too.

The binding can send

zigbee2mqtt/mydevice/color/set 46,102,193

but Zigbee2MQTT is expecting

{"color":{"r": 46,"g": 102,"b": 193}}

For On/Off and Color Temperature I got it working using the formatBeforePublish feature:


The problem with Brightness and Color Temperature is the value range (0-255 and 133-526) that can’t be send by using a slider or dimmer. With the old binding I used a JS transformation.

There is a discussion at the Zigbee2MQTT Github (" Option for non-JSON output #493") to get a feature that one can have the JSON path changed to MQTT channels but it seems to me that the intersection of openHAB and Zigbee2MQTT users is not that big.

Fortunately I got all my Xiaomi devices running with the new MQTT binding and Zigbee2MQTT. Transforming incoming JSON messages using transformationPattern is working very good so far.

1 Like

Thx, this helped alot. Finally i can control my lampy lamp with paper ui.


        Type switch : state "lamp" [ stateTopic="zigbee2mqtt/lamp", transformationPattern="JSONPATH:$.state", commandTopic="zigbee2mqtt/lamp/set", on="ON", off="OFF", formatBeforePublish="{\"state\":\"%s\"}" ]

Now it really publishes


to the topic. But holy, thats complicated.

Do you have already found a workaround for the rgb problem?

but it seems to me that the intersection of openHAB and Zigbee2MQTT users is not that big.

Think so too. Thats why i am running homeassistant and openhab parallel to compare and to find the best solution for me… the inbuilt discovery from hass is much better than ohab though.

We have that too but using a different MQTT convention (“Homie”). HA developers were really active in the meantime to push their MQTT HA components discovery into many open source projects and we have to catch up to promote our convention. Battle of the giants, I guess.

Yea i know, that’s no offense. I know ur putting much work into the addons. But do you maybe know if there is an alternative way to use zigbee2mqtt (or a similar tool) with e.g. homie convention, to get my zigbee gadgets connected without using a manufactorer’s (zigbee)gateway?

I’m using the deconz software on the same raspberry pi then openHAB and a 30€ raspbee Zigbee dongle.
The deconz software is emulating a hue bridge but with realtime support and we have a binding for that since OH 2.4.

At some point someone should add Homie to zigbee2mqtt. I’m just a bit busy with the new Paper UI design study at the moment.

Cheers, David

Thx for the tips and the great work!!