Restore_Mode: (ALWAYS_ON) Not really working

Hi Team,
I have a Gosund plug recently flashed with ESPhome, and all appears working except that “restore_mode: ALWAYS_ON” doesn’t really work.

Below is the relevant yaml.

Can someone guide me on anything that appears wrong?

substitutions:
  system_name: esph_laundry_drier_plug
  friendly_name: Esph Laundry Drier Plug
  restore_mode: ALWAYS_ON

esphome:
  name: ${system_name}
  platform: ESP8266
  arduino_version: 2.5.1
  board: esp01_1m

<-- CUT -- >

switch:
- platform: gpio
  name: "Relay Mains"
  id: switch1
  pin: GPIO14
  restore_mode: ${restore_mode}

Thanks,
~Bryan

What do you mean with “doesn’t really work”.

I think that if you want the state to survive power cycles you have to enable restore from flash:

I know this topic is quite old, still I will revive it as the problem sneaked its way all through to 2023 (2023.3.2 to be exact.)
restore_mode: ALWAYS_ON doesn’t have any effect on Gosund SP112 plug’s main relay. It will always turn off after every restart or power outage. esp8266.restore_from_flash also shows no influence on the behavior. I expected this this to be irrelevant as we are not trying to restore the previous state but have the relay “always on”.
Best workaround I came up with as a workaround is a regular switch.turn_on though I am not too happy with that solution.

interval:
  - interval: 10s
    then:
    - if:
        condition:
          switch.is_off: switch1
        then:
          - switch.turn_on: switch1
1 Like

I ran into this issue as well. I had some a few recent power outages and turning all the Gosund plugs each time was a pain. Especially since some are hard to reach.

I use them as switches for lights and/or air purifiers, which are not always on but controlled through HA.
So the solution to check and turn them on every 10 second would not work well in these cases.

I did find an alternative that I wanted to share and that is use the on_boot command which is document on the link from above (ESPHome Core Configuration — ESPHome).
Once the plug receives power it waits until all the services are started and then switches the relay to on as well as the light:

esphome:
  ....
  on_boot:
    priority: -100
    then:
      - switch.turn_on: relay
      - light.turn_on:
          id: led
          brightness: 100%
          transition_length: 0s

Your solution there helped me with a Sonoff Basic which refused to do anything else, using on_boot etc would all cause it not to boot at all. Thanks!