Can I make restore mode of a switch dependent of a sensor or a flash saved variable?

I have an ESP that controls power to the rest of the ESPs in my boat (so far 11, but they are grouped after bow, wheelhouse, wheelhouse ceiling and aft, so four groups). So when I leave the boat in the storm harbor, were I do not have power for maintenance charging (which i have to do tomorrow, for the second time in a week) I can use a single switch to turn off the power to all groups (I can do it individually with Hass or Node-RED) plus the two Pi’s. But how do I make sure that it stays off if the ESP should reboot for some reason? I don’t think a flash saved variable is possible on ESP32, from reading the documentation.

That means that the answer must be to make it dependant on the switch in some way. But I can’t see any way to do that in the documentation, under restore_mode. Is there something I can use for that? Or do I need to use on boot and set the priority to 800? What I would like to avoid is a quick flash of power to the devices. I have read (don’t remeber the source now) that it can damage both Pi’s and ESP32’s.

I was thinking wrong, by setting the switches to alwas off on boot, I could use an on_boot automation to make them turn on if the switch is on. If not, they don’t turn on at all. But I had to set the priority to 600, 800 seems to be before the switches are initialized.