I want to build a safety shut-off automation for a smart plug (switch.eve_energy_20ebo8301) used in a beauty studio. My girlfriend turns on a wax heater using this plug and usually turns it off manually after about 30 minutes.
As a safety net, I want an automation that automatically turns the plug off if it has been running continuously for 45 minutes.
My main concern is making this completely restart-proof and fail-safe. If Home Assistant restarts or crashes while the plug is active, I don't want the automation to miss the trigger and leave the heater running indefinitely.
What is the community's consensus on the best way to handle this? Should I rely on a state trigger with a duration combined with homeassistant.start and a template condition checking last_changed, or is using a helper like a timer with restoration enabled considered the more robust and reliable approach for safety-critical appliances?
Looking forward to your suggestions and best practices!
I think this is covered in the automation section of the cookbook...
There's a few cases in motion activated lights that cover restart safety and probably give an example.
Also watch that heater on that eve plug. I'm betting it's ride-ing the max amperage for that plug. You'll also want to watch it for burning out (suddenly unavailable)
For maximum resilience use an esphome based plug with on device logic like a timer which is fired after turning the device on and disables it after x time.
You are right to be concerned. I have a number of critical or safety loads where I use smart switches. I add extra tests for them.
Do what @NathanCu suggests and verify that the plug is rated for your use (and your load isn't near the limit of the switch load specification.
You really don't want to rely on just HA to turn it off. Check the device's parameters and use a switch that has a) overload protection, b) a "turn-off" timer as a fallback. Configure the auto-off to be just longer than your HA integration that turns it off.
Also configure the switch to start up in the off state in its parameters.
As for HA:
Consider using a timer helper for turning it off. Timers can survive a HA restart. (And pay attention to what happens when the timer finishes while HA is off.)
Turn the switch on via HA, and then unplug the switch and watch what happens in Dev Toosl to the device. Does it become "unavailable" in a reasonable amount of time? If so you can trigger on that and send an alert.
You can also look at {{ states.switch.your_switch.last_reported }} to see if it's been a long time since it last reported it's status.
If your switch reports power you can also look at that. This isn't for safety (well, maybe), but I have a switch on my coffee maker and after starting it I verify that it's drawing the expected amount of current.
One other tiny suggestion: Don't name your devices (and thus entities) after the device name, but after their function. Instead of switch.eve_energy_20ebo8301 how about switch.studio_wax_heater?
Do you know which smart plug from Amazon Germany does have that option onboard to turn off automatically after x minutes? Or how may I find such a model?
From Amazon Germany, most likely all of the Shelly devices can do this. You also have the choice where you can do a relay behind a regular plug, or do a smart plug.
"Almost all", as in a small set of those might not. So double check with spec sheets and/or verify with Shelly's Customer Service before you buy.