Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

How do you name your MQTT topics?

$
0
0

@quentinsf wrote:

When I program devices with, say, Tasmota, the default topic names tend start with the general category followed by the devoce name, like

tele/shelly-045678/state and
cmnd/sonoff-045678/power etc

but it seemed more natural to me to put the device first, and just number types of device as I buy them rather than using MAC addresses, so things would begin

sonoff_s20_1/tele/...
sonoff_s20_1/cmnd/...

That kind of made sense because I wasn’t always quite sure where I was going to use them when I first programmed them. I would give them more useful names in Home Assistant once they were actually plugged in/connected up, or whatever.

Now, however, I’m tempted to go back and use topic names based on locations in the house:

upstairs/laundry/tumbledryer/stat
outside/garage/light/1/cmnd/power

etc, since a human-readable name is always going to be more useful…
(I wonder, as an aside, if the HA MQTT auto-discovery stuff would pick up the new topics for a device if I changed them, or whether I’d need to delete the devices and re-add them, or start editing the .storage directory?)

Anyway, how do you name yours? In a flattish structure? By device, by type? Or in a more hierarchical fashion? Or do you just use the defaults?

I guess this might be driven by the kinds of subscriptions you think a system is going to make, and how that maps onto the slightly limited wildcard options available in MQTT. Are you, or your HA system, more likely to want to subscribe to all the topics relating to the garage, or all the topics relating to commands sent to lights, or…?

Keen to get ideas before I do a big tidying exercise :slight_smile:

Posts: 5

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>