No announcement yet.

Need advice on MQTT Best Practices

  • Filter
  • Time
  • Show
Clear All
new posts

    Need advice on MQTT Best Practices

    For the last year or so using Tasmota and mcsMQTT I was setting up the modules using Topic/Prefix thinking it makes more sense to have something like Plug87/Power rather than Power/Plug87. However the greater Tas community seems to configure it as Prefix/Topic, so I am wondering if I a missing something.

    Often when setting up the subscription I have to dig through the PI's Associations tab drop lists to extract things like the LWT or energy usage on these Costco plug modules.
    Using the setup below my thinking is that if I subscribe to the Plug87/Tele I would get all of the energy information, but this is not the case and often modules with the same basic setup don't behave the same way as I show in the 3rd picture.

    I am hoping I can have a better experience with MQTT and these devices with a few tweaks.
    Appreciate hearing your thoughts and your preferred practices.

    Attached Files
    Last edited by Kitar; June 18, 2021, 09:11 PM. Reason: Delete duplicate pics

    The image posted is not viewable.

    To my knowledge Tasmota, by default, uses Topic structure of %prefix%/%topic%. At my house I use %topic%. There are other tools that have been developed around Tasmota where the tool only supports the default %prefix%/%topic% structure. This means I cannot use these tools. As an an example a tool that shows all Tasmota devices on the network and the version of Tasmota installed in each.

    mcsMQTT does not care what you use for the Topic structure so it HS integration is the only issue then use something that makes sense to you and stick with whatever you have selected so you do not confuse yourself. I use %topic% because I want my Tasmota device to be the first thing in the topic and then other subordinate topic parameters still apply to the device. When %prefix%/%topic% is used then a sort by topic will show all the command topics together, all the status topic together, etc. This is not useful to me.

    There is no no right answer for "best". Whatever fits your thought process is "best" for you.

    I do not think Tasmota will use power/widget because power is not a prefix. Prefix is tele, stat, and cmnd. For a switch the topic will be stat/widget/power, tele/widget/power or cmnd/widget/power for the default. For %topic% template they will be widget/tele/power, widget/stat/power and widget/cmnd/power.