Blocking a firmware update from starting if GPIO/switch is on

Has anyone found a way to block a firmware update from starting unless GPIO is set to a specific state.
I want to prevent accidently pushing new firmware to the Shelly relay module that’s controlling power to the the LCD projector if its currently running. Since it shortens lamp life if you cut power to a projector without letting it do the cool-down period.

Hey

I don’t really understand your problem as updates have to be pushed manually from ESPHome panel in HA ! Also why push updates on ESPHome devices that work fine out of the chance to brick it ? the only case you need to do that is a breaking change between ESPHome and HA that has nearly never happened !

Vincèn

The problems is that it’s too easy to be editing ESPHome yaml configs on ESPHome panel in HA to reconfigure various things on the 10 shelly relays around the house and forget you’re editing the one that’s controlling the projector which is currently running. Or editing the one that’s controlling the power to the PC you are currently using.
And then there’s swearing, as it powers off the device you are currently using.
So it would be cool if there was a setting you could add to GPIO to block update based on state.

Set a password for ota.
If you really like to tinker, you could make a switch to remove password.
id(my_ota).set_auth_password(“”);

So automatically change the password between what it’s supposed to be and something else on switch state change. Since HA only knows what it’s supposed to be the update should fail if switch is in wrong state.
That’s pretty cool. Will give it a try tomorrow
Thanks.

Well for such ESPs I use most of time the

restore_mode: always_on

so I can reflash these devices without the hassle of power toggle during reboot :wink: Perhaps a viable solution for these specific devices ?

Pretty sure all GPIO go into reset start when the MCU reboots, so its still going to pulse off for a sec and kill the projector/pc with restore mode always on.

Well if you don’t care about what people tells you, sorry to say but take care of yourself :smiley:

All the relays go to its “normal” state, which means a normally open relay will open, but a normally closed relay will close.

The OTA component offers some triggers for automations and I’m pretty sure the switch state will be available at that moment. Have you tried to use that to cancel the ota itself?

I was thinking the other way around, giving a password that HA does not know and removing it with switch, but obviously it should work like that as well.

Interesting, ill have a look at that too.
Thanks.

No idea why you are getting upset.
Restore_mode is not intended to solve this issue, ESP8266 and ESP32 and practically every other MCU out there set all GPIO registers to off at startup. So there will always be a off-time glitch before code starts executing and restore mode takes affect.
If you’re saying it somehow works for you then you must being using some hardware that either has a filter on the output to the relays making them slower to deenergize, or you are relying on the fact that some switchmode powersupply can handle a short mains interruption without dropping their output voltage and rebooting the PC. While that may work in some situations it’s bad practice to rely on it.