MQTT Payload formatting

I have a MQTT to DALI Gateway that subscribe to 1 topic and controls devices with a payload message like: {“channel”: 1 , “value”: 0 } where 1 is the dimmer adress and 0 is the dim value (0 to 254).
suggestions on how to set this up? i would like to have one item(thing) per dimmer. Do i need to use rules/scripts?

What version of mqtt binding are you using?

could be the latest :wink: i am setting up a new openHAB machine…

Use a number channel, set your minimum and maximum values (0 and 254), and then you should be able to use the ‘outgoing value format’, like:

{ "channel": 1 , "value" : %d }

Thanx for your help on this.
but, I have not been able to migrate my “production machine” to 2.5 yet. is it possible to format this in 2.4 configfile?

Are you asking if you can use mqtt 2.x version on OH 2.4? If so the answer is yes but there is a bug. When you edit the mqtt files a restart of OH is needed. I don’t remember if just restarting the the mqtt bundle works but you can try.

Are you having issues with upgrading to 2.5?

i am mowing slowly to 2.5.2 :wink: and your suggestion of setting up 2.5 works fine! in the meantime i it would be nice to be able to format the payload in my running OH 2.4 .
String DALI_Lamp01 { mqtt=" >[housebroker:DALIgateway/subscribe:command: * :default]"}
where and how can i put the { “channel”: 1 , “value” : %d } formatting in this item?

The above syntax is for mqtt 1.x do you have that binding installed? You can use both mqtt 2.x and 1.x versions without issue.

Had to dig back a bit to find some of my old mqtt files but here they are:

Group:Switch:AND(ON, OFF) gSonoff
Switch LivingRoom_Light "Living Room Light" <light> (gSonoff) ["Lighting"] 
	{ mqtt=">[pibroker:cmnd/sonoff11/POWER:command:*:default],
	<[pibroker:stat/sonoff11-3C0826/POWER:state:default]" }

Switch CouchLight "Couch Light" <light> (gSonoff) ["Lighting"]
	{ mqtt=">[pibroker:cmnd/sonoff2/POWER:command:*:default],
	<[pibroker:stat/sonoff2/POWER:state:default]" }

Switch Test_Sonoff "Test sonoff2" <light> (gSonoff) ["Lighting"] //swapped with CouchLight 11/19/18
	{ mqtt=">[pibroker:cmnd/sonoff4/POWER:command:*:default],
	<[pibroker:stat/sonoff4/POWER:state:default]" }

Number LivingRoom_Light_RSSI "Living Room Light: RSSI [%d %%]" 
	{ mqtt="<[pibroker:tele/sonoff11-3C0826/STATE:state:JSONPATH($.Wifi.RSSI)]" }

Number LivingRoom_Light_Temp "Living Room Temp [%.1f °F]" <temperature> ["CurrentTemperature"]
	{ mqtt="<[pibroker:tele/sonoff11/SENSOR:state:JSONPATH($.SI7021.Temperature)]" }

Number LivingRoom_Light_Humidity "Living Room Humidity [%.1f %%]" <humidity>
	{ mqtt="<[pibroker:tele/sonoff11/SENSOR:state:JSONPATH($.SI7021.Humidity)]" }

Switch FrontPorch_Light "Front Porch Lights" <light> (gSonoff) ["Lighting"]
	{ mqtt=">[pibroker:cmnd/sonoff-7CB10D/POWER:command:*:default],
	<[pibroker:stat/sonoff-7CB10D/POWER:state:default]" }

Switch OfficeLight "Office Light" <light> (gSonoff) ["Lighting"] 
	{mqtt=">[pibroker:cmnd/sonoff55/POWER:command:*:default],
	<[pibroker:stat/sonoff55/POWER:state:default]" }

Switch ESP_Easy_Door "Esp8266 Garage" <light>
	{ mqtt="<[pibroker:Esp/Open/State:state:default],<[pibroker:Esp/Closed/State:state:default]" 	

    Switch ESP_Easy_Led "Esp8266" <light>
	{ mqtt=">[pibroker:/Esp/GPIO/13:command:ON:1],>[pibroker:/Esp/GPIO/13:command:OFF:0],
	<[pibroker:Esp/Led/State:state:default],<[pibroker:/Esp/Led/State:state:default]" }

Number ESP_Easy_Temp "Esp8266 Temp [%.1f °F]" <temperature>
	{ mqtt="<[pibroker:/Esp/DS/Temp:state:default]" } 

I didn’t have a String item but hope the example helps and if you need to see the map file use let me know as you may be able to do something similar.

Many of the outgoing MQTT payload formatting features were introduced between base releases 2.4 and 2.5. You may need a milestone release 2.4 binding to get them available on 2.4 (It’s a way of saying it’s make-work)

i cant find any “outbound” formatting so i will move to 2.5.2… i want to do it anyhow… thanks for your effort and help!

It’s in the docs
transformationPatternOut :
formatBeforePublish
min / max / step / unit/ on / off / onBrightness / stop all affect payload like mini-transforms