Skip to main content
🎀 Speaking at KubeCon EU 2026 Lessons Learned Orchestrating Multi-Tenant GPUs on OpenShift AI View Session
🎀 Speaking at Red Hat Summit 2026 GPUs take flight: Safety-first multi-tenant Platform Engineering with NVIDIA and OpenShift AI Learn More
OpenClaw + NUT
AI

OpenClaw + NUT: Smart UPS Monitoring and Graceful...

When the power goes out, OpenClaw coordinates the shutdown. Integrate NUT UPS monitoring for graceful power management on self-hosted infrastructure.

LB
Luca Berton
Β· 1 min read

Power Goes Out. Then What?

Jeff Geerling’s β€œNUT on my Pi” post resonated with every homelabber. Uninterruptible Power Supplies keep things running during outages β€” but someone needs to decide when to shut down. That someone is now OpenClaw.

The Setup

UPS (CyberPower 1500VA)
    β”‚ USB
    β–Ό
Pi 5 (NUT Server + OpenClaw)
    β”‚ Network
    β”œβ”€β”€ Pi (k3s cluster)
    β”œβ”€β”€ Pi (NAS)
    └── Switch

Installing NUT

# On the Pi connected to UPS via USB
sudo apt install nut

# Configure NUT
sudo cat > /etc/nut/ups.conf << 'EOF'
[cyberpower]
  driver = usbhid-ups
  port = auto
  desc = "CyberPower CP1500AVRLCD"
EOF

# Start NUT
sudo systemctl enable nut-server
sudo systemctl start nut-server

# Test
upsc cyberpower@localhost

OpenClaw Monitors NUT

Every heartbeat cycle, OpenClaw checks the UPS:

# Quick UPS status check
upsc cyberpower@localhost battery.charge
upsc cyberpower@localhost ups.status
upsc cyberpower@localhost battery.runtime

The Intelligence Layer

Here’s where OpenClaw beats a simple NUT script. Instead of β€œbattery below 20% β†’ shutdown everything,” OpenClaw makes smart decisions:

Scenario 1: Brief Outage

Power out. Battery: 95%. Runtime: 45 minutes.
β†’ OpenClaw: "Power outage detected. Battery at 95% (45 min runtime). 
   Monitoring. No action needed yet."
β†’ Waits quietly.
β†’ Power returns after 3 minutes.
β†’ OpenClaw: "Power restored. Total outage: 3 minutes. Battery at 92%."

Scenario 2: Extended Outage

Power out. Battery: 60%. Runtime: 25 minutes.
β†’ OpenClaw: "⚠️ Power out for 15 minutes. Battery at 60%.
   Plan: At 30% I'll shut down the NAS (save data).
   At 20% I'll shut down k3s workers.
   At 10% I'll shut down everything except myself."

Scenario 3: Critical

Battery: 15%. Runtime: 6 minutes.
β†’ OpenClaw: "πŸ”΄ CRITICAL: Battery at 15%. Initiating shutdown sequence."
   1. SSH to NAS: "sudo zpool export tank && sudo shutdown -h now" βœ…
   2. SSH to k3s nodes: "kubectl drain && sudo shutdown -h now" βœ…
   3. "All nodes shut down safely. I'll power off at 5%."
   4. Final message: "Going dark. Everything shut down clean. 
      I'll restart when power returns."

The Shutdown Script

#!/bin/bash
# /home/pi/graceful-shutdown.sh
# Called by OpenClaw when battery critical

echo "Phase 1: Stopping services"
ssh pi-nas "sudo systemctl stop jellyfin && sudo zpool export tank && sudo shutdown -h now"

echo "Phase 2: Draining k3s"
ssh pi-k3s-1 "kubectl drain pi-k3s-2 --ignore-daemonsets --force"
ssh pi-k3s-2 "sudo shutdown -h now"
ssh pi-k3s-1 "sudo shutdown -h now"

echo "Phase 3: Self-shutdown at 5%"
# OpenClaw will call: sudo shutdown -h now

Power-On Recovery

When power returns, the Pi (set to boot on power restore in BIOS/firmware) starts up, OpenClaw comes online, and:

  1. Checks which nodes are back
  2. Waits for NAS to boot and import ZFS pool
  3. Verifies k3s cluster health
  4. Sends recovery report:

βœ… Power Restored β€” Recovery Complete Outage duration: 1 hour 23 minutes All 4 nodes back online ZFS pool: ONLINE, no errors k3s: 23/23 pods running UPS: Charging (currently 34%)

UPS Sizing

For my 30W homelab:

CyberPower 1500VA / 900W
Actual load: 30W
Runtime at 30W: ~2+ hours
Cost: $150

That's 2+ hours of grace period. More than enough for most outages.

The UPS doesn’t just keep things running β€” combined with OpenClaw, it orchestrates a clean shutdown and recovery. No data loss, no ZFS corruption, no orphaned pods.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens TechMeOut