Migration MQTT to 2.4

Any message means ON or literally any number means ON and non-numbers mean OFF? Ignored?

Any message means ON

OK, then I think this will work.

Assuming you are running OH 2.5 M1 (which you should because of many bug fixes in MQTT 2 binding immediately after 2.4 released there is a new default value in the Map transform. So if you create a .map file containing


and apply that transform to the incoming Channel any message should get transformed to ON.

Thank you @rlkoshak
One more thing, can you explain this rule from here: https://www.openhab.org/addons/bindings/mqtt.generic/

rule "Publish all"
      Channel "mqtt:broker:myUnsecureBroker:myTriggerChannel" triggered
   //this is variable where all incoming messages is stored separated by # 
   val parts = receivedEvent.split("#")
   //but i do not understand this line 
   sendCommand(parts.get(0), parts.get(1)

This is to replace part of the replacement for the EventBus capability. The Rule get’s triggered for all messages published to the myTriggerChannel. The receivedEvent implicit variable carries the event as a String. The format of the String is <topic>#<value>.

So when events are received on the topic we can command the Item of the same name with the value. Thus you can sort of federate OH instances over MQTT by having them publish all events and using a Rule like this to synchronize them.

Since i install new MQTT binding (2 days ago), i have 2 mqtt_v_1 stops. This was never happen before. And strange, mqtt v1 cannot reconnect to broker, only OH restart helps (i try to restart mosquitto service - doesnt help). I use same name “zbox” on mqtt1 and “zbox” in bridge mqtt2 - is this possible fail reason?
OH 25M1 Xubuntu x86

Most likely. Each needs to have it’s own client ID. Only one client with a given client ID can be connected to the broker at a time. When a client tries to connect with the same ID as a client already connected, the broker will kill the connection to the already connected client and use new connection instead.

Hi Mate, do you have a corresponding item file for these lamps ?

Hi, after several months I have now decided to migrate to MQTT 2.4.
Most of items are simple ON/OFF item with On=1", Off=0", but I also have some LEDS with a fadein/out and strange on/off message.
With MQTT1 the item was:

Switch	LED_Cucina	    {mqtt=">[localbroker:/N17_LEDCucina/cmd:command:ON:pwm,12,1023,2000],           >[localbroker:/N17_LEDCucina/cmd:command:OFF:pwm,12,0,2000],             <[localbroker:/N17_LEDCucina/LED_Cucina/OUT:state:OFF:0],          <[localbroker:/N17_LEDCucina/LED_Cucina/OUT:state:ON:255],",        autoupdate="false"}`

How can I create an equivalent thing/item in MQTT2.4 ?
Thanks for your help

As described above and in many of the links in the thread above, assuming you have the binding set up and a Broker Thing created and it shows as online.

  1. Create a Generic MQTT Thing
  2. Set the outgoing topic to “/N17_LEDCucina/cmd”
  3. Set the incoming topic to “/N17_LEDCucina/LED_Cucina/OUT”
  4. Configure custom ON and OFF values (1 and 0 respectively)
  5. Link the new Channel to your Item, keep autoupdate=“false”

Thanks RIch,
This is clear to me but I need to send :
as ON command “pwm,12,1023,2000”, as OFF command “pwm,12,0,2000”
while for the state the binding receive “255” as ON and “0” as OFF

How can I solve this issue with the 2.4 binding?


If they are fixed values, use the custom ON/OFF value fields. If not, use a transform.

Thanks Rich… solved but I have created 4 map files … probably due to my poor knowledge :laughing: