Ensure Smart Home Reliability: Integrating Your UPS with Home Assistant
- #homeassistant

Ensure Smart Home Reliability: Integrating Your UPS with Home Assistant
In the world of smart homes, we often focus on convenience, automation, and cool gadgets. But what happens when the power goes out? Without power, your Home Assistant server, network equipment (modem, router, switches), smart home hubs (Zigbee, Z-Wave), and critical devices cease to function. Integrating an Uninterruptible Power Supply (UPS) with Home Assistant is not just a good idea; it's a fundamental step towards building a truly resilient and reliable smart home.
A UPS provides temporary battery power during an outage, giving your critical devices time to continue operating. More importantly, by integrating the UPS with Home Assistant, you can monitor its status and automate actions, such as notifying you of a power failure, turning off non-essential devices to conserve battery, or performing a graceful shutdown of your systems before the battery runs out.
Why Integrate a UPS with Home Assistant?
- Maintain Critical Functions: Keep your Home Assistant server, network, and security systems online during short outages.
- Prevent Data Loss/Corruption: Ensure your Home Assistant database and configuration files are not corrupted by sudden power loss through automated graceful shutdowns.
- Automated Responses: Trigger automations based on power status (e.g., turn on essential lights, disable high-power appliances).
- Monitoring & Peace of Mind: Know the battery level, load, and estimated runtime directly within Home Assistant.
Prerequisites
To follow this guide, you'll need:
- A UPS with a data communication port (usually USB or Network/Ethernet). Common protocols include USB HID, USB PowerCOM, or network-based protocols supported by NUT.
- Your Home Assistant instance (HAOS, Supervised, Docker, or Core).
- A way to connect the UPS data port to the machine running Home Assistant or another machine on your network that can act as a NUT server.
- Network access between your Home Assistant instance and the machine connected to the UPS (if not the same machine).
Understanding Network UPS Tools (NUT)
Home Assistant integrates with UPS devices primarily through the Network UPS Tools (NUT) project. NUT is a powerful open-source suite that provides a common interface for monitoring and managing a wide variety of UPS hardware. It uses a client-server model: a nut-server
(or upsd
) service runs on the machine directly connected to the UPS (the 'server'), and nut-client
(or upsc
) services on other machines (the 'clients') can query the server for UPS status. Home Assistant acts as a NUT client.
In many Home Assistant installation types (like Home Assistant OS or Supervised), a NUT server is built-in or easily installed as an add-on, allowing Home Assistant itself to be the machine directly connected to the UPS via USB. In other setups (like Home Assistant Core in a Python environment or Docker), you might need to run a separate NUT server on another machine (e.g., a Raspberry Pi, NAS device, or even your router if it supports NUT).
Setup Steps: Integrating NUT with Home Assistant
The easiest way to integrate NUT with recent versions of Home Assistant is via the UI.
1. Physical Connection
Connect the data cable (typically USB Type-A to Type-B) from your UPS to the machine running Home Assistant. If you are using a separate machine as a NUT server, connect the cable to that machine instead and ensure the NUT server software is installed and configured there.
2. Installing and Configuring NUT Server (If Necessary)
- Home Assistant OS/Supervised: The official NUT add-on can install and configure the server for you. Install it from the Add-on Store, configure it (specifying the UPS driver and port), and start it. The add-on essentially runs the
upsd
andupsmon
NUT services. - Other Systems (Docker, Core, Separate Machine): You'll need to install the NUT package (e.g.,
sudo apt-get install nut
on Debian/Ubuntu), configureups.conf
(to tell NUT about your UPS hardware and driver) andupsd.conf
/upsmon.conf
(for network access and monitoring). This is a more advanced process and details vary by OS and UPS model. Consult the official NUT documentation and your UPS manufacturer's specifications for the correct driver and connection details.
Once the NUT server is running, test it locally on the server machine using upsc ups_name@localhost
(replace ups_name
with the name you configured in ups.conf
). This command should return a list of variables from your UPS.
3. Adding the NUT Integration in Home Assistant
Assuming your Home Assistant instance can communicate with the machine running the NUT server (either itself via USB or a remote machine via the network):
- In Home Assistant, go to Settings > Devices & Services.
- Click the + Add Integration button in the bottom right.
- Search for "NUT" or "Network UPS Tools".
- Select the integration.
You will be prompted for connection details:
- Host: The IP address or hostname of the machine running the NUT server (e.g.,
127.0.0.1
orlocalhost
if the NUT server is on the same machine and listening on the local interface, or the LAN IP of your dedicated NUT server machine). - Port: The port the NUT server (
upsd
) is listening on (default is 3493). - Username (Optional): If you configured user authentication in
upsd.conf
. - Password (Optional): If you configured user authentication.
- UPS Name: The name you gave your UPS in the NUT server's
ups.conf
file (e.g.,myups
,smartups
).
- Host: The IP address or hostname of the machine running the NUT server (e.g.,
- Click Submit. Home Assistant should connect to the NUT server and discover the available sensors.
- Select the entities you want to enable and click Finish.
Home Assistant will create a device representing your UPS and various sensor entities reporting its status (battery level, status, load, input voltage, etc.).
Device Integration and Entities
Once the integration is successful, navigate to Settings > Devices & Services > Entities and filter by the NUT integration or your UPS device name. You will see a list of entities like:
sensor.your_ups_name_battery_level
(Percentage)sensor.your_ups_name_status
(States likeonline
,on battery
,low battery
,charge
,discharge
)sensor.your_ups_name_load
(Percentage of maximum load)sensor.your_ups_name_runtime
(Estimated seconds or minutes remaining)sensor.your_ups_name_input_voltage
(Volts)- And many others depending on your UPS model and the NUT driver.
These entities are the building blocks for your power-related automations.
Automation Examples
Leverage the UPS entities to create critical automations:
1. Notify on Power Failure
Send a notification when the UPS switches to battery power.
alias: Notify - Power Outage Detected
description: Send notification when UPS goes on battery
trigger:
- platform: state
entity_id: sensor.your_ups_name_status
to: 'on battery'
condition: []
action:
- service: notify.your_notification_service
data:
title: "⚠️ Power Outage Detected"
message: "Home is now running on UPS battery power."
mode: single
2. Shutdown Non-Essential Devices
When on battery, turn off high-power-consuming devices that aren't critical (e.g., washing machine, dryer, desktop computers).
alias: Power Saving - On Battery Mode
description: Turn off non-essential devices when on UPS battery
trigger:
- platform: state
entity_id: sensor.your_ups_name_status
to: 'on battery'
condition: []
action:
- service: homeassistant.turn_off
data: {}
target:
entity_id:
- switch.washing_machine
- switch.desktop_computer
# Add other non-essential high-draw entities here
mode: single
3. Graceful System Shutdown
This is crucial. Shut down Home Assistant and potentially other connected systems (like a NAS) before the UPS battery is exhausted.
alias: System Shutdown - UPS Critical Battery
description: Shutdown systems when UPS battery is low
trigger:
- platform: state
entity_id: sensor.your_ups_name_status
to: 'low battery'
# Or trigger based on runtime remaining:
- platform: numeric_state
entity_id: sensor.your_ups_name_runtime
below: 300 # Shutdown if less than 5 minutes runtime remaining (adjust as needed)
condition: []
action:
- service: notify.your_notification_service
data:
title: "⚠️ UPS Battery Critical"
message: "UPS battery is low. Initiating system shutdown."
- delay:
seconds: 10 # Give time for notification to send
- service: homeassistant.stop # Use homeassistant.stop or homeassistant.shutdown
mode: single
The homeassistant.stop
or homeassistant.shutdown
service will attempt to gracefully stop the Home Assistant instance. If you have other systems (like a NAS or another server) also running NUT clients connected to the same UPS server, you can configure them to shut down based on the same critical battery condition reported by the NUT server.
Best Practices for Reliability
- Size Your UPS Correctly: Calculate the total power draw (in Watts) of the devices you intend to connect to the UPS (Home Assistant server, network gear, critical hubs). Choose a UPS with a VA (Volt-Ampere) and Watt capacity significantly higher than your total load. This ensures you get reasonable runtime and don't overload the UPS.
- Connect Only Essentials: Avoid connecting non-critical, high-draw devices like monitors, printers, or entertainment systems to the UPS battery outlets. Use the surge-protected-only outlets for these if available on your UPS.
- Test Your Setup: Periodically simulate a power outage by unplugging the UPS from the wall (when load is low, preferably during the day). Verify that Home Assistant detects the change, sends notifications, triggers your power-saving automations, and most importantly, successfully executes the graceful shutdown automation when the battery level is low.
- Monitor UPS Health: Keep an eye on the battery age (UPS batteries degrade over time) and perform self-tests if your UPS supports it. Some UPS units report battery health via NUT.
- Review Logs: If the integration isn't working or automations fail, check the Home Assistant logs and the NUT server logs for clues.
Conclusion
Integrating your UPS with Home Assistant provides crucial resilience against power interruptions. By leveraging the NUT integration, you gain visibility into your power backup status and the ability to automate responses that protect your data, maintain essential services, and ensure a smooth shutdown process. This significantly enhances the reliability and robustness of your smart home ecosystem, moving beyond simple automation to true smart home management.

NGC 224
Author bio: