Mastering Power Resilience: Integrating Network UPS with Home Assistant for Smart Shutdowns

NGC 224
DIY Smart Home Creator
In the evolving landscape of smart homes, reliability and resilience are paramount. While we often focus on connectivity and automation, the foundational element – power – is frequently overlooked until an outage strikes. A power failure can disrupt automations, damage sensitive electronics, and corrupt data on critical servers like your Home Assistant instance or network-attached storage (NAS). This is where a Network Uninterruptible Power Supply (UPS) becomes indispensable. By integrating your network UPS with Home Assistant, you transform a passive power backup into an intelligent, active guardian of your smart home.
Why Integrate Your UPS with Home Assistant?
A UPS provides crucial battery backup during power interruptions, giving your devices time to shut down gracefully or continue operating for a limited period. Integrating it with Home Assistant unlocks a new level of control and insight:
- Real-time Monitoring: Get instant updates on power status, battery level, load, and estimated runtime directly within your Home Assistant dashboard.
- Proactive Notifications: Receive alerts via your Home Assistant companion app, email, or even voice assistants when power is lost or the battery is running low.
- Automated Shutdowns: Trigger graceful shutdowns of Home Assistant, NAS, and other critical servers before the UPS battery is depleted, preventing data corruption.
- Conditional Device Control: Automate the shutdown of non-essential devices (e.g., high-power appliances, non-critical lights) to extend the runtime for essential equipment.
- Historical Data: Log power events and UPS performance over time, helping you understand your power consumption patterns and identify potential issues.
Prerequisites for Integration
Before diving into the setup, ensure you have the following:
- A Network UPS: This is a UPS with network connectivity, typically supporting either Network UPS Tools (NUT) protocol or Simple Network Management Protocol (SNMP). Popular brands like APC, Eaton, and CyberPower often provide this capability.
- Home Assistant Instance: Running on a device that can communicate with your UPS over the network (e.g., Home Assistant OS, Docker, Supervised).
- Network Configuration: Ensure your UPS has a static IP address and is accessible from your Home Assistant instance.
Integration Method 1: Network UPS Tools (NUT)
NUT is a powerful, open-source software suite designed for monitoring and managing UPS devices. Many network UPS units have a built-in NUT server or can be configured to expose their data via NUT.
Step-by-Step NUT Integration
- Enable NUT on Your UPS: Consult your UPS's documentation to enable its built-in NUT server. This usually involves enabling a specific service or daemon and setting up a username/password for monitoring access. Note down the UPS's IP address and the NUT port (often 3493). Some UPS models might require a separate piece of software (like PowerChute Network Shutdown for APC) to expose NUT data.
-
Add NUT Integration in Home Assistant:
- Navigate to Settings > Devices & Services in Home Assistant.
- Click + ADD INTEGRATION and search for "Network UPS Tools (NUT)".
- Enter the IP address of your UPS, the NUT port (default is 3493), and the username/password you configured on the UPS.
- Submit the configuration. Home Assistant should automatically discover various sensors.
-
Identify Key Sensors: Home Assistant will create a variety of sensors based on what your UPS exposes. Look for entities like:
sensor.your_ups_battery_charge
(percentage)binary_sensor.your_ups_online
(on/off)sensor.your_ups_load_percentage
(current load)sensor.your_ups_runtime_remaining
(minutes)
Integration Method 2: SNMP (Simple Network Management Protocol)
If your UPS doesn't support NUT directly or you need access to specific data points not exposed via NUT, SNMP is a robust alternative. Many network devices, including UPS units, support SNMP for network management.
Step-by-Step SNMP Integration
- Enable SNMP on Your UPS: Access your UPS's web interface or management software and enable SNMP. Configure a community string (read-only for monitoring, e.g., "public") and ensure SNMP v1/v2c is enabled (v3 for added security if supported by HA's SNMP integration). Note down the UPS's IP address.
-
Configure SNMP Sensors in Home Assistant: The SNMP integration in Home Assistant requires manual configuration in your
configuration.yaml
.
Finding OIDs: This is the trickiest part. You'll need your UPS's MIB (Management Information Base) file, usually available from the manufacturer's website. Tools like Paessler SNMP Tester or# configuration.yaml snmp: - host: 192.168.1.100 # Replace with your UPS IP address community: public # Replace with your SNMP community string base_oid: 1.3.6.1.4.1.318.1.1.1.2 # OID for APC UPS health/status version: 2c sensors: - name: "UPS Battery Charge" oid: 1.3.6.1.4.1.318.1.1.1.11.1.2.1.0 # Common OID for battery charge unit_of_measurement: "%" value_template: "{{ value | int }}" - name: "UPS Status" oid: 1.3.6.1.4.1.318.1.1.1.4.1.1.0 # Common OID for UPS status value_template: "{% set status_map = {1: 'Unknown', 2: 'Online', 3: 'On Battery', 4: 'Low Battery', 5: 'Replace Battery', 6: 'Shutdown', 7: 'Bypass', 8: 'On Line and Bypass'} %} {{ status_map[value | int] if value | int in status_map else 'Unknown' }}" - name: "UPS Load Percentage" oid: 1.3.6.1.4.1.318.1.1.1.4.2.3.0 # Common OID for load unit_of_measurement: "%" value_template: "{{ value | int }}" - name: "UPS Estimated Runtime" oid: 1.3.6.1.4.1.318.1.1.1.2.2.3.0 # Common OID for runtime unit_of_measurement: "minutes" value_template: "{{ value | int / 60 }}" # If OID gives seconds, convert to minutes
snmpwalk
(Linux command-line tool) can help you browse the OIDs exposed by your UPS. -
Restart Home Assistant: After modifying
configuration.yaml
, restart Home Assistant for the changes to take effect.
Building Smart Automations
With your UPS data flowing into Home Assistant, the possibilities for automation are vast.
1. Instant Power Outage Notifications
Trigger an alert the moment your UPS switches to battery power.
# automation.yaml
- alias: 'UPS Power Loss Notification'
trigger:
platform: state
entity_id: binary_sensor.your_ups_online # Or sensor.ups_status if using SNMP
to: 'off' # Or 'On Battery' for SNMP
action:
- service: notify.mobile_app_your_device
data:
message: "❗ Power outage detected! UPS is on battery power."
title: "Smart Home Power Alert"
- service: media_player.play_media
target:
entity_id: media_player.google_home_speaker # Or other notification service
data:
media_content_id: "media-source://tts/google_translate?message=Power outage detected. UPS is on battery power."
media_content_type: 'music'
2. Graceful Shutdown of Critical Systems
This is arguably the most crucial automation. When the UPS battery reaches a critically low level, initiate shutdowns.
# automation.yaml
- alias: 'UPS Low Battery Shutdown'
trigger:
platform: numeric_state
entity_id: sensor.your_ups_battery_charge
below: 10 # Trigger when battery drops below 10%
condition:
condition: state
entity_id: binary_sensor.your_ups_online
to: 'off' # Ensure it's actually on battery power
action:
- service: notify.mobile_app_your_device
data:
message: "⚠️ UPS battery critically low ({{ states('sensor.your_ups_battery_charge') }}%). Initiating shutdown of critical systems."
title: "CRITICAL Power Alert"
- service: shell_command.shutdown_nas # Example for NAS via SSH/API
- service: homeassistant.stop # This will gracefully stop Home Assistant
# Add more actions for other devices/servers as needed
For shell_command.shutdown_nas
, you'd define this in your configuration.yaml
:
# configuration.yaml
shell_command:
shutdown_nas: 'ssh user@your_nas_ip sudo /sbin/poweroff'
Important: Ensure SSH keys are set up for passwordless login if using ssh
in shell_command
.
3. Optimize Battery Usage by Disabling Non-Essentials
Extend runtime by switching off high-draw, non-critical devices.
# automation.yaml
- alias: 'UPS On Battery - Disable Non-Essential Devices'
trigger:
platform: state
entity_id: binary_sensor.your_ups_online
to: 'off'
action:
- service: switch.turn_off
target:
entity_id:
- switch.gaming_pc_power_plug
- light.decorative_lighting_group
- service: notify.mobile_app_your_device
data:
message: "Non-essential devices powered off to conserve UPS battery."
Best Practices for a Resilient Ecosystem
- Test Your Setup Regularly: The only way to know your power resilience plan works is to test it. Simulate a power outage by unplugging your UPS from the wall (briefly!) and observe if automations trigger as expected. Do this during off-peak hours and inform household members.
- Monitor Battery Health: UPS batteries have a finite lifespan. Regularly check the battery health status provided by your UPS (often available as a sensor in HA) and consider replacing batteries every 3-5 years, or as recommended by the manufacturer.
- Understand Your Load: Keep an eye on your UPS's load percentage. Overloading a UPS will drastically reduce its runtime. If you add more devices, ensure your UPS can handle the additional load.
- Graceful Shutdown Order: If you have multiple critical systems (NAS, Home Assistant, media servers), plan their shutdown order. Typically, you'd shut down data-sensitive systems first, then Home Assistant itself.
- Document Your Configuration: Keep a record of your UPS's IP, NUT/SNMP settings, and any custom OIDs or templates. This will be invaluable for troubleshooting or future upgrades.
- Consider UPS Type: For sensitive electronics, a “pure sine wave” UPS is generally recommended over a “simulated sine wave” or “square wave” UPS, as it provides cleaner power output.
Conclusion
Integrating your network UPS with Home Assistant is a proactive step towards building a truly resilient and reliable smart home. It moves beyond simple power backup, empowering you with critical insights and automated responses to power fluctuations. By investing a little time in this integration, you safeguard your smart home infrastructure, prevent data loss, and ensure your automations continue to function even when the lights go out, offering true peace of mind.

NGC 224
Author bio: DIY Smart Home Creator