ESPhome restore mode: toggle

Hello everybody

Could you possibly help me with ESPhome configuration for sonoff basic (mini).

I tried hard to get the same behavior as i have in the tasmota: (Power on state : toggle.)

I tried to use “restore mode” but it doesn’t have option - toggle.

I need to toggle the sonnoff relay from the previous state when i cut the power for a short period of time using the self returning wall switch.

Thanks in advance

Use on_boot: to do a one time activity.

Thanks
I tried this:

esphome:
  name: tableswitch
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -10
    then:
    - switch.toggle: relay

wifi:
  ssid:XXX
  password: XXX

api:

logger:

ota:


switch:
  - platform: gpio
    pin: GPIO12
    id: relay
    restore_mode: RESTORE_DEFAULT_ON



status_led:
  pin:
    number: GPIO13
    inverted: yes

But it doesn’t work

Could you please use </> in the text bar to paste your code into. It will retain code spaces and formatting. Thanks. I suspect the restore mode is overriding the on_boot. So is it you want to toggle the state that existed before the power cycle? Maybe try setting the priority to -100 instead of -10.

yes, exactly. I want to toggle restored state
Tried -100 , doesn’t work (

2 Likes

OK. First I’d check that the state is correctly restored after reboot without the on_boot: added. If it’s always on then the last state isn’t being saved correctly. Assuming it is I would indent the - switch statement two more spaces and try it.

Also did you enable the restore functionality?

ESP8266 Options:

  • esp8266_restore_from_flash ( Optional , boolean): Whether to save & restore data from flash on ESP8266s. Defaults to no . See esp8266_restore_from_flash for more info

HI
I tried restore_mode: RESTORE_DEFAULT_ON

It worked and done the job I am looking for.

Thanks bro…