In a power loss situation, I understand that it is important to do a graceful shutdown of HA so you don’t have corrupted database files. My understanding the same is true for a Linux OS, but maybe not so critical.
I want to implement a procedure to handle a power loss situation for my Raspberry Pi 5 running the HA OS. Here’s my setup:
- Raspberry Pi 5 with HA OS installed. Pi is plugged into a Sonoff WiFi Smartplug, which is plugged into a Tripp-Lite UPS battery.
- I also have a Zigbee device to detect power loss in my home.
The UPS can power my Wifi Router, Cable Modem, and Raspberry Pi 5 for about 45 minutes.
The method I’m trying to implement with an HA automation is this:
- When there is a home power outage my sensor triggers an HA automation.
- The automation sends me a notification, and starts a 30 minute countdown.
- If the power isn’t restored by that time, the automation does a graceful HA shutdown.
- When the home power returns, I can toggle the switch on the Sonoff WiFi outlet to restart the Pi and HA.
- If the home power doesn’t return before the UPS’ battery is exhausted, the Pi will be turned off.
With this approach I’m not doing a graceful shutdown of the Linux system on the Pi, which might be a problem. Should I be concerned about the Pi? If so, is there a way I can start a cron job from HA to shutdown the Pi after HA has shutdown?
Thanks.