Tasmota + restart homeassistant = wrong status

Hello,

I’m running homeassistant with 3 tasmota devices.
In hass, they are discovered with following entity ID’s:

  • switch.tasmota
  • switch.tasmota_2
  • switch.tasmota_3

and displayed as

  • Tasmota
  • Tasmota
  • Tasmota

I know I can override the display name, but I decided to configure my tasmota devices manually as follows:

# =================================================
# SONOFF
# TASMOTA firmware
# =================================================
switch:
  - platform: mqtt
    name: "Tasmota-105"
    state_topic: "tasmota-105/stat/RESULT"  
    value_template: "{{ value_json.POWER }}"
    command_topic: "tasmota-105/cmnd/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    availability_topic: "tasmota-105/tele/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    qos: 1
    retain: false

I configured lovelace with entity

  • switch.tasmota_105

This works fine. I can control my Tasmota device with homeassistant.

However, after restarting homeassistant, I noticed that the status of de tasmota devices is NOT correctly displayed.
In example:

  • Tasmota-105 has status “ON”
  • I restart homeassistant
  • Tasmota-105 has status of “OFF” in the gui (but is “ON” in reality)

The original discoverd “switch.tasmota_2” (wich is the same as my manually configured “switch.tasmota_105”) has correct behaviour: after restarting homeassistant, the switch stays on “ON”

Question:
how can I configure my tasmota device manually so that it’s status is showed correctly after restarting homeassistant?

Currently working through issues like this myself.
What I had to do was issue the following command in my Tasmota console:
Please read the docs here so you know what each command does.

powerretain 1
SetOption19 1
SetOption59 1

For good measure I turned off each plug, unplugged it, plugged it back in.

Once I set these I went to “Configuration -> Integrations -> and deleted MQTT” Do not restart HA the integration will persist. I rebooted my mosquitto broker, went back to “Configuration -> Integrations -> and install MQTT” again. Set auto-discovery to on and in a few minutes everything should be reporting as it should.
If I recall correctly setting powerretain 1 can cause retained messages to crop up on the “switch” so I used MQTT Explorer to check for my cmnd messages from the switches and if there are retained messages just delete them there and you should no longer have this issue.
There was a really helpful video on YouTube here that explains retain packages and when you do and don’t want them.

Hopefully that helps you.

1 Like