New MQTT Binding whats your thoughts

For me, it was a shock to find that the MQTT binding had a major “upgrade” to the extent that the previous binding is no longer available ( or rather from what I could find). I will be brave and report that I don’t like it and please disagree with me :slight_smile: .
I spent the better part of today working through the binding and here are my thoughts.

I can appreciate that one would like to configure item and devices through the paper ui and get to some sort of plug and play but, MQTT does not have a universal standard and there are so many different ways it can be implemented in IOT.
My system has the following devices running off MQTT

  • Arduino_Mega that control 24 relays and have 32 inputs - the main brain of the system

  • About 10 or 12 Tasmota Devices (Wemos and SonOff) that have some temp sensors and or other sensors including motion sensors for the outside buildings.

  • SonOff POW to monitor power consumption

  • Victron Inverter running its own MQTT server

None of these complies to the standard of the new MQTT Binding and therefore needs to be manually configured. To do this, in bulk, the text base is still the “quickest” but where one would add the items and then link to the site map you will now need to

  1. Create an MQTT Bridge with the “Items” / things with a completely new format
  2. Create the Items
  3. Link items to the Sitemap

As the format has changed completely the only way to “migrate” your system to the new binding is to redo the complete OH2 setup from scratch. If you start fresh with a new system it could be less of an annoyance but you will most likely need to setup up the sitemap via text base anyway and there in the fun start as the opportunity to make syntax mistakes are plentiful.
Below is an example of a Sonoff device setup that I used for the last year or so

Old setup :
mqtt.cfg - Once off


sonoff.items “Page”

// Pressure Pump
	Switch pressurepump	 			"Pressure Pump"  	 (out_switches, CF)	 	{ mqtt=">[broker:cmnd/pressurepump/POWER:command:*:default],<[broker:stat/pressurepump/POWER:state:default]" }
	String pressurepump_Reachable 	"Pressure Pump: Status [%s]" (gReachable)	{ mqtt="<[broker:tele/pressurepump/LWT:state:default]" }
	Number pressurepump_RSSI 		"Pressure Pump: RSSI 	[%d %%]"  			{ mqtt="<[broker:tele/pressurepump/STATE:state:JSONPATH($.Wifi.RSSI)]" }
	Number pressurepump_vcc 		"Pressure Pump: Vcc  	[%.2f v]"	  		{ mqtt="<[broker:tele/pressurepump/STATE:state:JSONPATH($.Vcc)]" }
	Number pressurepump_uptime 		"Pressure Pump: Uptime [%.0f min]"			{ mqtt="<[broker:tele/pressurepump/STATE:state:JSONPATH($.Uptime)]" }
	String pressurepump_ip_get 		"Get IP" 									{ mqtt=">[broker:cmnd/pressurepump/IPAddress:command:*:default]" }
	String pressurepump_ip			"Pressure Pump: ip [%s]" 					{ mqtt="<[broker:stat/pressurepump/ip:state:default]" }

and then the
Sitemap (Extract)

Text item= pressurepump_Reachable valuecolor=[Last_Update=="Offline"="red"]			icon="sonoff1"
						Frame { Text item=pressurepump_RSSI 			icon="network"
								Text item=pressurepump_vcc				icon="energy"
								Text item=pressurepump_uptime			icon="clock"
								Switch item=pressurepump_ip_get 		mappings=[""="Current Ip"]
								Text item=pressurepump_ip 				icon="ipicon1"	

Compare to the new Setup

mqttConnections.things ;
mqtt:broker:mainBroker2018 [ host=“”,secure=false ]

The MQTT bridge ;
sonoff.things ;

Bridge mqtt:broker:mainBroker2018 [ host="", secure=false ]
    Thing topic sonoff {
// Pressure Pump
Type switch : pressurepump					"Pressure Pump "					[ stateTopic="stat/flat_pressurepump/POWER", commandTopic="cmnd/flat_pressurepump/POWER"]
Type string : pressurepump_Reachable		"Pressure Pump : Status " 			[ stateTopic="tele/pressurepump/LWT"	]
Type number : pressurepump_RSSI 			"Pressure Pump : RSSI"				[ stateTopic="tele/pressurepump/STATE",transformationPattern="JSONPATH:$.Wifi.RSSI"]
Type number : pressurepump_vcc				"Pressure Pump: Vcc"				[ stateTopic="tele/pressurepump/STATE",transformationPattern="JSONPATH:$.Vcc"]
Type number : pressurepump_uptime 			"Pressure Pump: Uptime"				[ stateTopic="tele/pressurepump/STATE",transformationPattern="JSONPATH:$.Uptime"]
Type string : pressurepump_ip 				"Pressure Pump: ip"					[ stateTopic="stat/pressurepump/ip"]	

The Items Page

> // Flat Pressure pump
> Switch flat_pressurepump	 		"Flat Pressure pump" 				(out_lights, Lights)		{ channel="mqtt:topic:mainBroker2018:24relay:flat_pressurepump" }
> String flat_pressurepump_Reachable 	"Flat Pressure pump: Status [%s]"								{ channel="mqtt:topic:mainBroker2018:24relay:flat_pressurepump_Reachable" }
> Number flat_pressurepump_RSSI 		"Flat Pressure pump: RSSI [%d %%]"								{ channel="mqtt:topic:mainBroker2018:24relay:flat_pressurepump_RSSI" }
> Number flat_pressurepump_vcc 		"Flat Pressure pump: Vcc  	[%.2f v]"							{ channel="mqtt:topic:mainBroker2018:24relay:flat_pressurepump_vcc" }
> Number flat_pressurepump_uptime 	"Flat Pressure pump: Uptime [%.0f min]"							{ channel="mqtt:topic:mainBroker2018:24relay:flat_pressurepump_uptime" }
> String flat_pressurepump_ip			"Flat Pressure pump: ip [%s]" 									{ channel="mqtt:topic:mainBroker2018:24relay:flat_pressurepump_ip" }

Sitemap ;

			Text item= pressurepump_Reachable valuecolor=[Last_Update=="Offline"="red"]		icon="sonoff1"
					Frame { Switch item=pressurepump					icon="sonoff1"
							Text item=pressurepump_RSSI 				icon="network"
							Text item=pressurepump_vcc					icon="energy"
							Text item=pressurepump_uptime				icon="timer"
							Text item=pressurepump_ip 					icon="ipicon1"	

Apart from the Sitemap every MQTT node (Used in nodered) and devices will need to be redone and apart from the possible auto detection of some devices I cant see any other benefits.

Would it not be possible to simplify the “generic” version of MQTT and still have the option to auto detect or have the option to pick the old MQTT rather than the new one?

Please keep in mind that is just my viewpoint and I still appreciate all the work and effort that has gone into this binding and I also am well aware that shouting from the couch is the easiest thing to do but here is my 5c worth.

I will take the comments to chin in an attempt to help with making OH even better!

You can still use the old 1.x binding just need to enable legacy binding in PaperUI and then you’ll have the option to install the 1.x mqtt binding.

1 Like

Ah , super thank you already one lesson learned!

1 Like

@Paul_F_Prinsloo here’s a YouTube video you may find interesting.

Hope you find it informational.:smiley:


Most definitely , thank you. One more lesson learned! I guess it will be another steep learning curve coming!
Thank you for taking the time to post the info!

Always glad to help.:wink:

I’m sure you’ve seen the link about the 2.x architecture but I’ll provide it for others that haven’t.

1 Like

My tl;dr is I don’t like how it rolled out. It should not have just replaced everyone’s working and installed 1.x binding like it did. And those users like you who were not aware of the “Show Legacy 1.x Bindings option” were really caught unawares.

But the new binding over all was necessary and in many ways an improvement over the 1.x version binding.

It’s there but you have to enable “Show Legacy 1.x Bindings” under Configuration System for it to appear in the list. And you can run them in parallel so you can migrate at your leisure.

Not quite. You DO need to create a new MQTT Broker Thing with the connection parameters to your existing broker. Then you need to create a new Generic MQTT Thing. Next create a new channel for each of your MQTT configs on your Items. Finally link the Channels to your Items by replacing the mqtt="< blah blah blah" with channel=“channel id” between the { } on your existing Items.

What I’ve done is create the Bridge and the Thing and one or two channels in PaperUI. Then closed openHAB and used copy/paste/edit on the JSONDB file to create the rest of the Channels I needed. I’ve since rolled most of that back because I decided to take this opportunity to make those devices I do have control over comply with Homie so will wait until I achieve that to fully migrate over to the new binding.

Or you can continue to use the 1.x version of the binding for the foreseeable future. You don’t have to upgrade now or even soon.

This is true of ANY 1.x binding to 2.x binding. They are fundamentally different is so many ways it is simply impossible to make a copy and paste configuration upgrade. I totally agree that the new binding should not have just replaced your old one, but it will never be the case where migration from a 1.x to 2.x version of the binding will be copy and paste.

Probably not or else it would have been coded like that in the first place.

You do have this option.

Just a question. How many OH1 bindings are you using? :slight_smile:
(OH1 bindings are those that don’t do any Things/Channels and are configured via the Items files).

Cheers, David

On my old system only one - MQTT :rofl: - now on the new setup zero. I am migrating the system :slight_smile:

1 Like