MQTT - structure / usage

I’m looking for some suggestions on MQTT structure and usage at the start of my home automation journey.

For example, I have a lamp in the living room, currently controlled by a Sonoff basic.

Which of the following approaches do you use / would you recommend for controlling the lamp via MQTT within nodered / homeassistant / etc:

  • Use the standard Tasmota MQTT structure and publish to cmnd/livingroom-lamp/POWER directly.

  • Use a custom topic such as home/livingroom/lamp/set which provides some abstraction away from the device actually controlling the lamp’s relay. Then I could create a flow in nodered which subscribes to this topic and then publishes to the Tasmota directly. This way if I ever change the relay control device I just need to rewrite that flow, but can still publish to home/livingroom/lamp/set (leaving other nodered or home assistant config alone).

Hello,

This is an involved topic. Here is what I have. I installed Sonoffs circa 2017. I’ve recently updated them and gone to a more standard topic structure. This is for the Sonoffs and also the BSD01 devices which are Tuya smart switches flashed with Tasmota. I’ve been leaning more and more towards “what is the default for the device” and run with that. I do add Tasmota/ on the front of the MQTT Topic.

I think you are on the right track. I found it is more important to identify the device hardware than the location. The home automation software can map devices to more human names. When troubleshooting, I don’t want to drag out a translation table to see what device is failing.

1 Like