Tasmota binary_sensor via MQTT reverts to off upon restart

Tags: #<Tag:0x00007f739c142370> #<Tag:0x00007f739c1422a8> #<Tag:0x00007f739c1421b8>

I have a Tasmota sensor with “SensorRetain 1” set. I also have “recorder” set in my configuration.yaml. Every time I restart Home Assistant, the binary_sensor reverts to off, even though it is on.

What am I missing here?

Did you use tasmota auto-discovery or did you configure manually ?

Auto-discovery. “SetOption19 1” is set.

Can you check with MQTT Explorer if the ‘retain’ flag is set ?

Thanks for the tip on this. MQTT Explorer is pretty cool.

tele/watermainsensor/LWT has the retain flag, but STATE and SENSOR do not. I also have “SwitchRetain 1” set.

Here’s another wierd thing. According to Tasmota, these messages are being sent regularly (every 5 minutes).

22:55:17 MQT: tele/watermainsensor/SENSOR = {"Time":"2020-06-04T22:55:17","Switch1":"ON"} (retained)
23:00:17 MQT: tele/watermainsensor/SENSOR = {"Time":"2020-06-04T23:00:17","Switch1":"ON"} (retained)
23:05:17 MQT: tele/watermainsensor/SENSOR = {"Time":"2020-06-04T23:05:17","Switch1":"ON"} (retained)
23:10:17 MQT: tele/watermainsensor/SENSOR = {"Time":"2020-06-04T23:10:17","Switch1":"ON"} (retained)

Repeated ON messages (with retained!). Yet, HA still believes the switch is OFF.