As mentioned in my ‘Getting Started’ post, I create separate ‘devices’ for my different Arduino sketches, such as mqtt-LED, mqtt-fire2012xy, mqtt-mesh, and so on. In addition, I may have more than 1 of each type of lantern displaying at the same time. To do so, I will serialize each lantern (it’s in the code) and using a combo box widget, I can then select one or ALL of each device type and publish that to the broker, which will then get picked up by the subscribing device. I’ll then use another widget to send hue, brightness to other information to the selected devices.
In order to support these multiple device types (aka sketches), I’ll add a device prefix to the topic.
For a fire2012 lantern, the published topic can look like this: