Home assistant don't restore switch state on dashboard after reboot home assistant

  • Docker Home Assistant 0.60.0
  • sonoff basic with ESPEasy_R120 firmware
  • in the configuration.yaml are present:

mqtt:

light:

platform: mqtt
name: “sonoff1”
state_topic: “/sonoff_01/gpio/12”
command_topic: “/sonoff_01/gpio/12”
payload_on: “1”
payload_off: “0”
optimistic: false
qos: 0
retain: true

recorder:

history:

Step by step:

  • I turn on the switch through the dashboard HA
  • reboot HA
  • the dashboard shows that the switch is off, the history tab also shows that it is off, although it is on.

How to restore the relay state on dashboard HA?

Not sure, because not using ESPEasy, but you can try setting the “MQTT retain message” in ESPEasy.
https://www.letscontrolit.com/wiki/index.php/ESP_Easy_web_interface#Tools_Advanced_page

Likewise, not using ESPEasy, but you need to find the equivalent of Tasmota’s “PowerRetain - Enable MQTT power retain on status update” which fixes exactly your issue.

What @VDRainer has suggested looks promising so definitely worth a try.

I tried “MQTT retain message” in ESPEasy, but it’s no work(

Same in this topic.
I don’t know if the embedded mqtt broker can work with retained messages.
Maybe you try with mosquitto?

1 Like

Yes, problem with embedded mqtt. With mosquitto works fine

1 Like

how do you use mosquitto?

i can’t seem to get it to start?

my sonoff just keeps flashing green and clicking on/off/on/off etc