Openhab 2/3 - MQTT V1 conversions

I’ve got a smoke detector that could send out something (via PAI) on an open topic or fire topic. Under V1 Mqtt I do this with:

Contact		alarm_smoke_computer			"Computer Smoke State [%s]"		<fire>	(g_smoke_detection) 
										{ mqtt="<[openhab:paradox/states/zones/Smoke_computer/open:state:MAP(],

What woulc be the equivalent thing defintion for the v2 binding? I’ve currently got open state:

Type contact : zSmoke_computer		"zSmoke_computer"		[ stateTopic="paradox/states/zones/Smoke_computer/open", on="True", off="False" ]

and item:

Contact 	alarm_smoke_computer        "Computer Smoke State [%s]"	<fire> 			(g_smoke_detection) { channel="mqtt:topic:alarm:zSmoke_computer"}

But can I

  • Have mulltiple MQTT topics for a thing channel
  • or Have multiple item links to multiple thing channels?

You can link as many items to channel as you like

openHAB 3 is a little different and you might want to go straight to that as the main UI is much better


UID: mqtt:topic:RPI4:Smoke
label: "Smoke alarms "
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:RPI4
  - id: Computer
    channelTypeUID: mqtt:switch
    label: Burning server
    description: ""
      stateTopic: paradox/states/zones/Smoke_computer/open
      off: "False"
      on: "True"

How do I do that in 2.5.9? I got a few thing to convert off v1 bindings so will migrate those first before looking at 3 (and would prefer 3.0.1/3.1).

What’s the syntax for multiple channels for an item? Just with commas?

Yep that’s how you add more than one channel to an item.

I not sure why you would wait for OH3.1 its just a number. Yes there will be issues with it however if you are going to have unique problems with the system then it will happen anyway.

After the snapshots of oh3 there were 5 milestone releases and 2 release candidates before the release.

Beause I have more than just this alarm still using mqtt v1. A couple on things on nut v1. I’d rather not have a dead system.

So back on mqtt. As far as I know a stateTopic and CommandTopic can’t take different values can they?

Type switch : bFamily_room_PIR	"bamily_room_PIR"	[ commandTopic="paradox/control/zones/Family_room_PIR", on="bypass", off="clear_bypass", stateTopic="paradox/states/zones/Family_room_PIR/bypassed" ]

To bypass a zone, I send bypass or clear_bypass for on and off. But the resulting state is true/false.
How can I achieve this?

You would need to use transformation pattern to change it to what you want.

You need MAP transformation installed

Create a MAP file in your transform folder named or whatever


Then your channel will look like

Type switch : bFamily_room_PIR	"bamily_room_PIR"	[ commandTopic="paradox/control/zones/Family_room_PIR", transformationPatternOut="" , transformationPattern="", stateTopic="paradox/states/zones/Family_room_PIR/bypassed"]

To convert generally from v1 to v2:

Through PaperUI. If you have a number of very similar MQTT Things you might need to create, when using PaperUI I recommend create the first one. Then from the REST API query for the newly create Thing, copy the JSON to a text editor and modify it for your new similar thing and submit the edited JSON to create the new Thing. I’m so glad to bid good riddance to PapeRUI.

There has been a NUT 2 binding out for quite some time. It is feature complete with the v1 binding.

Here’s another one. Very easy with mqttv1. Broadlink mini. For channels (or source). The topic is the button where the command for on/off is replay.

String rm3_lounge_samsung_source         "Source" (g_rm3_lounge_samsung) {mqtt=">[openhab:broadlink/34ea34b2f9c5/tv/samsung/tv:command:tv:replay],

String rm3_lounge_samsung_channel_select "Select Channel" (g_rm3_lounge_samsung) {mqtt=">[openhab:broadlink/34ea34b2f9c5/tv/samsung/numone:command:1:replay],

Do I have to set each “channel”, ie each topic as a new channel each. Can I assigned all of these channels to a single string item, or do they need to be defined as 1 switch per channel, and operate it that way?



String rm3_lounge_samsung_channel_select { channel="mqtt:topic:...", channel="mqtt:topic:...", channel="mqtt:topic:...", channel="mqtt:topic:...",  }

Might be easier, but we don’t know what you’re doing with the String Item at the moment.

Any pointers to the item config that would work for this? And how to set the various channels?

From a UI point of view, what is it that you’re after? As in, what do you want to be able to do to change your TV channel? What are you doing at the moment?

So channels, I have their names

And the nance translate to a number, 1,2,3 etc. this is done in the sitemap

Group item=g_rm3_lounge_samsung label="TV Lounge" {
			Switch item=rm3_lounge_samsung_power
			Switch item=rm3_lounge_samsung_volume
			Switch item=rm3_lounge_samsung_mute
			Switch item=rm3_lounge_samsung_channel
			Selection item=rm3_lounge_samsung_source mappings=[hdmi1="Apple TV",hdmi2=PC,hdmi3=Playstation,hdmi4=Chromecast,tv=TV]
			Selection item=rm3_lounge_samsung_channel_select mappings=[1="One",2=Two,3="+HRE=E",4="Bravo",5="Maori",6="One+1",7="Two+2",8="+HRE=E+1",9="Bravo+1",10="Prime",11="The Edge",12="Choice",13="Duke"]
		} //Group item=g_rm3_lounge_samsung label="TV Lounge"

This will be tricky with the current method of topics and commands (replay) that you’re using. However, based on this presumably you’re using the broadlink-mqtt project? (I’m not a stalker, honest - just recognise the username!)

If so, then instead of:

  • TOPIC: broadlink/34ea34b2f9c5/tv/samsung/numtwo
  • MESSAGE: replay

You can do:

  • TOPIC: broadlink/34ea34b2f9c5/tv/samsung/
  • MESSAGE: numtwo

This makes your configuration much simpler. I don’t know how your Bridge Thing is set up - I’ll assume you have everything in the same file. You can then have the following device Thing:


Thing topic TVSamsung "Samsung TV"  {
		Type string : swChannel "TV Channel" [


String rm3_lounge_samsung_channel_select "TV Channel" {channel="mqtt:topic:TVSamsung:swChannel"}


Selection item=rm3_lounge_samsung_channel_select label="Channel []" mappings=[numone="One",numtwo="Two",numthree="+HRE=E",numfour="Bravo",numfive="Maori",numsix="One+1",numseven="Two+2",numeight="+HRE=E+1",numnine="Bravo+1",numten="Prime",numeleven="The Edge",numtwelve="Choice",numthirteen="Duke"]

Ha yeah, I still use that, but must use an older one that doesn’t support that format…still use my original fork for multiple devices.

I might have to move to simplify the messaging as you’ve described as that is much simpler.

Well, if it’s any use: just yesterday I integrated a second Broadlink device into my network, and the current version of the broadlink-mqtt seems to be handling it very well!

yeah he didn’t dockerise his, so just need to get that working for mine (I have braoadlink-mqtt running in my iot network). I think I can pull his changes to mine and do it from here.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.