Skip to content

MQTT Retains and Power States

digiblur edited this page Feb 2, 2021 · 6 revisions

Home Assistant Power States

To ensure Home Assistant has the latest power state(s), dimmer states, etc from your Tasmota devices, add the automation below to your automation.yaml file. If you have changed the default GroupTopic from the default of "tasmotas" on any of your devices you will need to publish to any additional or changed GroupTopics. This automation cause all of the devices to report their relay states at any Home Assistant restart.

Issuing a "PowerRetain 1" command on the Tasmota console is also recommended. See this video for more information: https://youtu.be/dbSw6VkI-x4 (MQTT Retained Messages - The Love Hate Relationship)

- alias: "Tasmota State on HA Restart"
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/backlog"
        payload: "power1 ;power2 ;power3 ;power4 ;power5; dimmer; state "
    - service: mqtt.publish
      data:
        topic: "cmnd/tasmotas/backlog"
        payload: "power1 ;power2 ;power3 ;power4 ;power5; dimmer; state "