Raspberry PI UPS with Automatic Shutdown

By Daniel Samson, CO-AUTHORED-BY: CLAUDE OPUS 4.8 <NOREPLY@ANTHROPIC.COM> · 2026-06-08

A few weeks ago my area had a three-hour power outage. I wasn't home for most of it, but my home-lab was — and it did not cope gracefully.

The incident

I walked through the front door to find my Eaton Series 3S 850VA / 510W UPS emitting a continuous, ear-splitting buzz. It had exhausted its battery after roughly an hour, taking my entire network down with it for the remaining two hours of the outage.

For anyone unfamiliar: a UPS (Uninterruptible Power Supply) sits between the wall and your equipment. When mains power drops, it switches to battery so your gear keeps running — at least until the battery runs dry. The idea is to give you a clean bridge, either long enough for power to return, or long enough to shut everything down safely.

My Eaton does have a USB connection that can signal when it's on battery. That's fine for a single machine sitting next to it. It doesn't scale to the 15 nodes I'm running across the lab. I needed something different.

What I actually needed

I sat down and wrote out three hard requirements for whatever I built next:

  • Power all my networking gear for at least five hours — enough to outlast most outages without me needing to intervene.

  • A centralised detection mechanism that every node in the cluster can query, rather than one USB cable to one machine.

  • Power pass-through while the battery is charging — I don't want to run on battery during normal operation.

The solution

Three components make this work together.

power-setup.png

Jackery Explorer 1000 v2

This is the battery. The Jackery Explorer 1000 v2 is a portable power station with a 1kWh capacity, AC pass-through while charging, and enough outlets to feed all my networking gear comfortably. At typical home-lab networking loads it'll run for well over five hours. It charges off mains like any other device, so in normal operation the equipment is effectively on pass-through and the battery sits topped up in the background.

jackery-box.jpg

Shelly Plus Plug

The Shelly Plus Plug sits on the mains feed going into the Jackery. It exposes a local HTTP API and reports real-time power draw. When mains power drops, the plug's reported wattage falls to zero — that's the signal. Every node in the cluster can poll a single endpoint to find out whether the grid is up or not. No USB cables, no per-node configuration, no vendor lock-in.

shellyplusuk.png

ragnarok — the shutdown daemon

Each node runs a small Python daemon I've called ragnarok. The name felt appropriate. It does four things:

  1. Periodically polls the Shelly plug to check whether mains power is present.

  2. Decides, based on how long the outage has lasted and the battery's remaining capacity, how long the node can safely keep running.

  3. Cordons the node in the cluster so no new workloads are scheduled onto it.

  4. Shuts the node down cleanly.

The whole thing is event-driven and autonomous. If the power goes out at 3am and I'm asleep, the cluster gracefully winds itself down before the battery runs flat — no screaming buzzer, no corrupted volumes.

zeus and observability

Alongside ragnarok, I have a power app called zeus that can toggle the master switch on the Shelly plug — useful for remote cycling or forcing a controlled shutdown event during testing. Power consumption is also scraped into Prometheus and visualised in Grafana, so I can see exactly what the lab is drawing at any point and get a realistic picture of how long the battery would last under current load.

power-grafana.jpg

The next three-hour outage can do its worst. The cluster will handle it.