MQTT1 items with multiple PUB SUB -->> migrate to MQTT 2.x

I agree with rossko57. The generally considered best practice is:

  • each device is represented by a separate Thing
  • if there is more than one actuator or sensor on that Thing, each is represented by a Channel

From there you have two choices. You can link multiple channels to the same Item or you can link only one channel to individual Items. You could then use rules or, as rossko57 indicates, you can use Groups. When you send a command to a Group, the command gets forwarded to all of it’s members. So, for example, you would define KitchenLightSwitch1 as

Group:Switch:OR(ON,OFF) KitchenLightSwitch1

Then you would have three separate Items for the three devices:

Switch KitchenLightSwitch1_Kitchen (KitchenLightSwitch1) { channel="thing id that pub/sub to myhome/kitchen/light/switch/row1/command" }
Switch KitchenLightSwitch1_SwitchBoard (KitchenLightSwitch1) { channel="thing id that pub/sub to myhome/switchboard/switchboard1/command" }
Switch KitchenLightSwitch1_HMI (KitchenLightSwitch1) { channel="thing id that pub/sub to myhome/HMI/page0/kitchen/light/switch/row1/state" }

KitchenLightSwitch1 will be ON if any of it’s members are ON. Sending a command to KitchenLightSwitch will be forwarded to all of the members.

If you do not follow the Group approach, you can put all the channels on the one Item, but you will probably need to use the follow profile on the switchboard and hmi channels. My only concern here is that I don’t know how/whether the follow profile will work with more than one channel following.

Given that you are driving some other external UI, if you have control over the MQTT topics that it publishes/subscribes to, you might be able to do away with configuring MQTT on these Items at all and use MQTT 2.5 Event Bus (I’ve recently rewritten this to make setup and use a little simpler).