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.
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.
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