Restart Home Assistant (Pi 4 + UPS) after power outage

So my configuration is as follows:

  • Raspberry Pi 4 with Home Assistant OS
  • UPS battery, connected via USB and NUT
  • Automation that tells HA to shut down the host when the UPS goes below 30%

This is working fine and shuts down HA in a sane manner before the power is completely lost. However, when the power is restored and the UPS charges again, HA does not boot again, because the Raspberry was still technically connected to a power source all the time. I then have to manually unplug and replug the Raspberry power supply to boot everything up again.

While this works well enough when I’m at home, I would like a solution that also reliably works completely unattended.

Any ideas on how to achieve this?

Thanks, Eiko

1 Like

How long do your power outages last?

Your Pi draws very little power and should be able to run for quite a while on a UPS battery. If the more power-hungry devices on the UPS shut down at 30%, maybe your Pi can continue going until say 5% or 10% which hopefully outlasts 99% of power-cuts??

edit: Another thought. You could have an automation which disables all other automations when running on UPS battery (thereby reducing the power usage of the Pi to it’s minimum) and re-enables them when the Pi is back on mains? Now, 30%➜10% on the UPS battery is even longer.

My Pi is on a UPS as well, but when the UPS battery has gone, my Pi just stops. This rarely happens, but at least it powers-up again automatically.

My Home Assistant Pi (that also runs some Docker images like Homematic) is the only device connected to the UPS. Unfortunately it either draws quite some power or my USV has a really bad battery. Here is the graph:

So it takes exactly 30min from 100% to 30% with a load of “5%” (whatever that means in Watt). Since the load always is in the 4% to 5% range I suspect that disabling automations won’t do much.

I really don’t want the Pi to turn off tue to power loss. My last experiences with that included broken SD cards, filesystem errors and hard to trace down weird bugs in Homematic (which runs as an Addon / Docker image on that Pi).

I just had a thought:

Maybe I can put a Shelly Plug S between the UPS and the Pi so that in case of a power outage (which I’m notified about somehow) I can use my Fritz!Box VPN and the Shelly web interface to recycle power and thus restart the Raspberry Pi. Now I would just need to find a way to automate that…

I’m guessing the UPS never disconnects power to the Pi. Hmmmm Chicken and Egg problem… Time to think…

Hello,

I’m also interested in this topic.

I have approximatively the same configuration:

  • HA on Pi 3 with UPS on USB
  • No automation for shutdown Pi, this is done by the NUT add-on when UPS power is low
  • Also a Synology as a UPS client that listen for “shutdown” event from UPS server (on NUT add-on on HA)

The fact is the same: HA + Synology shuts down when receiving UPS event, but when power comes back while the UPS is still alive, none of the Pi or Synology wake up.
Keeping the Pi online is not a priority for me, so no problem if it stops, as long as it is able to start again when i’m not at home.

On Synology, when you set it with UPS on USB, it is possible to send a shutdown command to UPS: so it stops, and everything stops. When power is back, everything start again.
But with NUT with HA, it is not possible.
A PR has been made some time ago for that about the NUT add-on but not accepted (Shutdown ups by abhi23768 · Pull Request #36 · hassio-addons/addon-nut · GitHub).

Same issue here.
My rpi4 can last around 4 hours on 2x18659 3000 mAh, but when I shut it down it doesn’t boot up back. Maybe I should leave some USB light on so it drain the battery.

As for the Synology UPS client, I have a solution:

  1. my APC UPS connected via USB to HASSIO.
  2. I’m running NUT server on HASSIO
  3. My Synology is connected to Network NUT and configured to shutdown after 10 minutes on battery

I’m using this action to shutdown the UPS

  - type: shutdown_reboot
    device_id: 1a5fc62def0e5cb3305b6270df784e09
    domain: nut

Not sure to understand when you say you use that action to shutdown the ups: who launches that action ? Hassio ? How can it launch that if it is itself shutdown by the nut event ?

I’m running hassio on rpi4 with UPS hat.
I have a dedicated APC UPS which supply the Synology NAS
APC UPC connected to HASSIO via USB.
On power outage I’m sending command from Hassio to APC UPS to shutdown
I’m using INA219 UPS HAT Integration to monitor UPS hat and when it’s close to the end I’m shutting down HASSIO

But hassio won’t start itself on power back as UPS Hat never drain itself to 0

Just wondering if anyone has figured this out? I’m running HAOS on a bare metal NUC11 connected via USB to a APC BackUPS 1350. I can create an automation to shutdown the host but once the host is shutdown I don’t see anyway to boot the host again after power is restored.