🧩 UniFi UPS Tower integration with Home Assistant

UniFi UPS Tower integration with Home Assistant

NUT, notifications, dashboard

After setting up my UniFi UPS Tower with Home Assistant and fine-tuning notifications,
I wanted to share a stable, working configuration for anyone using UniFi UPS devices.


:jigsaw: Tested setup

  • UniFi UPS Tower 1000VA 230V – firmware 1.4.12
  • UDM-SE connected via NUT client port
  • Home Assistant 2025.10.x (Yellow / CM5)
  • iPhone 15 Pro with critical notifications
  • All devices on LAN 192.168.233.x
    :white_check_mark: Stable for 24 h with no false triggers
    :zap: Tested with real power outage simulation (5 min runtime)

:gear: How to set it up (step-by-step)

  1. Enable the NUT server on your UniFi UPS Tower

    • Open the UPS Tower web interface (you can find its IP in UniFi Controller).
    • Navigate to Settings → Network → NUT Server.
    • Enable the NUT server.
    • Set a simple device name, e.g. UPS (this name is used in all NUT commands).
    • Save the settings and reboot the UPS if necessary.
  2. Find the UPS IP address

    • In UniFi Controller → Devices → UPS Tower → Network tab.
    • Example: your_ups_ip
  3. Verify that the NUT service is reachable

    • From a terminal on your computer: (example nc -vz 192.168.1.44 3493)
      nc -vz your_ups_ip 3493
      
      You should see something like:
      Connection to your_ups_ip port 3493 [tcp/nut] succeeded!
      
  4. List available UPS variables

    • Test communication with:
      echo -e "LIST VAR UPS\n" | nc your_ups_ip 3493
      
      Example output:
      VAR "UPS" "battery.charge" 91
      VAR "UPS" "ups.status" "OL CHRG"
      VAR "UPS" "battery.runtime" 3649
      
  5. Add the sensors in Home Assistant

    • Copy the YAML block below into your configuration.yaml under command_line:
      or place it in a separate file, e.g. sensors/ups.yaml.
  6. Reload the configuration

    • In Home Assistant go to:
      Settings → Developer Tools → YAML → Reload Command Line Entities
      (or simply restart Home Assistant once).
  7. Add the automation

    • Paste the automation YAML (see below) under
      Settings → Automations → YAML mode
      to receive critical iOS notifications when the UPS changes state.
  8. Test the setup

    • Simulate a short power outage by unplugging the UPS input.
    • Wait ~25–30 seconds for the updated readings and the notification to appear.
  9. Add a dashboard card

    • Use the provided Mushroom dashboard example below.
    • Adjust entity names as needed to match your setup.

:brick: Configuration (command_line sensors)

Copy the following YAML into your configuration.yaml under command_line:
or into a separate file such as sensors/ups.yaml.

command_line:
  - sensor:
      name: "UPS Battery Charge"
      command: "echo -e 'GET VAR UPS battery.charge\\n' | nc your_ups_ip 3493 | awk '{print $4}'"
      unit_of_measurement: "%"
      value_template: "{{ value | float(0) }}"
      scan_interval: 20

  - sensor:
      name: "UPS Runtime"
      command: "echo -e 'GET VAR UPS battery.runtime\\n' | nc your_ups_ip 3493 | awk '{print $4/60}'"
      unit_of_measurement: "min"
      value_template: "{{ (value | float(0)) | round(0) }}"
      scan_interval: 20

  - sensor:
      name: "UPS Input Voltage"
      command: "echo -e 'GET VAR UPS input.voltage\\n' | nc your_ups_ip 3493 | awk '{print $4}'"
      unit_of_measurement: "V"
      value_template: "{{ value | float(0) }}"
      scan_interval: 20

  - sensor:
      name: "UPS Output Power"
      command: "echo -e 'GET VAR UPS output.power\\n' | nc your_ups_ip 3493 | awk '{print $4}'"
      unit_of_measurement: "W"
      value_template: "{{ value | float(0) }}"
      scan_interval: 20

  - sensor:
      name: "UPS Load"
      command: "echo -e 'GET VAR UPS ups.load\\n' | nc your_ups_ip 3493 | awk '{print $4}'"
      unit_of_measurement: "%"
      value_template: "{{ value | float(0) }}"
      scan_interval: 20

  - sensor:
      name: "UPS Status Short"
      command: "echo -e 'GET VAR UPS ups.status\\n' | nc your_ups_ip 3493 | awk '{print $4}' | tr -d '\"'"
      value_template: >-
        {% set v = value | trim %}
        {% if v in ['unknown', '', 'unavailable'] %}
          {{ states('sensor.ups_status_short') }}
        {% else %}
          {{ v }}
        {% endif %}
      scan_interval: 20

  - sensor:
      name: "UPS Status"
      command: "echo -e 'LIST VAR UPS\\n' | nc your_ups_ip 3493 | grep 'ups.status' | awk '{for (i=4; i<=NF; i++) printf $i \" \"; print \"\"}' | tr -d '\"'"
      value_template: >-
        {% set v = value | trim %}
        {% if v in ['unknown', '', 'unavailable'] %}
          {{ states('sensor.ups_status') }}
        {% else %}
          {{ v }}
        {% endif %}
      scan_interval: 20

:bell: Automation – Critical Power Notifications

:iphone: Example notifications

(real screenshots from the test setup)


This automation sends iOS critical push notifications whenever the UPS switches
between line power and battery mode.
It includes a 30-second delay to ensure the sensors have updated values.

alias: UPS – Status change notifications (critical + delay)
description: >
  Sends iOS critical notifications when the UPS switches between line and battery.
  Includes a 30s delay for reliable sensor refresh.
triggers:
  - entity_id: sensor.ups_status_short
    to: OB
    trigger: state
  - entity_id: sensor.ups_status_short
    to: OL
    trigger: state
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.ups_status_short
            state: OB
        sequence:
          - delay: "00:00:30"
          - service: notify.mobile_app_karoly_iphone_15_pro
            data:
              title: ⚡ Power outage – UPS on battery
              message: >
                The UPS has switched to battery mode.  
                Battery: {{ states('sensor.ups_battery_charge') }}%  
                Runtime: {{ states('sensor.ups_runtime') }} minutes.
              data:
                push:
                  sound:
                    name: default
                    critical: 1
                    volume: 1
          - service: logbook.log
            data:
              name: UPS
              message: Switched to battery mode (OB)
              entity_id: sensor.ups_status_short

      - conditions:
          - condition: state
            entity_id: sensor.ups_status_short
            state: OL
        sequence:
          - delay: "00:00:30"
          - service: notify.mobile_app_karoly_iphone_15_pro
            data:
              title: 🔌 Power restored – UPS back on line
              message: >
                The UPS is now back on mains power.  
                Status: {{ states('sensor.ups_status') }}  
                Battery: {{ states('sensor.ups_battery_charge') }}%
              data:
                push:
                  sound:
                    name: default
                    critical: 1
                    volume: 0.7
          - service: logbook.log
            data:
              name: UPS
              message: Returned to line mode (OL)
              entity_id: sensor.ups_status_short
mode: single

:bulb: Tip:
Make sure your iPhone notifications are configured to allow Critical Alerts
for the Home Assistant app — otherwise the push won’t bypass Silent/DND mode.

:desktop_computer: Example Dashboard View (Mushroom)

Below is a simple, clean dashboard card setup using Mushroom (legacy) cards
to display key UPS information — status, power, charge, load, voltage, and runtime.
You can freely adjust colors or entity names as needed.

Here’s how the UPS status overview looks in Home Assistant
using Mushroom legacy cards and the stack-in-card layout:

type: custom:stack-in-card
mode: vertical
cards:
  - type: custom:mushroom-title-card
    title: 🧠 UniFi UPS Tower – Status Overview
    subtitle: Power state, charge, runtime, load
    alignment: center

  - type: horizontal-stack
    cards:
      - type: custom:mushroom-legacy-template-card
        entity: sensor.ups_status
        primary: UPS Status
        secondary: "{{ states('sensor.ups_status') }}"
        icon: mdi:power
        icon_color: green

      - type: custom:mushroom-legacy-template-card
        entity: sensor.ups_battery_charge
        primary: Battery
        secondary: "{{ states('sensor.ups_battery_charge') }} %"
        icon: mdi:battery
        icon_color: green

      - type: custom:mushroom-legacy-template-card
        entity: sensor.ups_output_power
        primary: Power
        secondary: "{{ states('sensor.ups_output_power') }} W"
        icon: mdi:flash
        icon_color: yellow

  - type: horizontal-stack
    cards:
      - type: custom:mushroom-legacy-template-card
        entity: sensor.ups_load
        primary: Load
        secondary: "{{ states('sensor.ups_load') }} %"
        icon: mdi:gauge
        icon_color: green

      - type: custom:mushroom-legacy-template-card
        entity: sensor.ups_input_voltage
        primary: Input Voltage
        secondary: "{{ states('sensor.ups_input_voltage') }} V"
        icon: mdi:power-plug
        icon_color: green

      - type: custom:mushroom-legacy-template-card
        entity: sensor.ups_runtime
        primary: Runtime
        secondary: "{{ states('sensor.ups_runtime') }} min"
        icon: mdi:timer
        icon_color: blue

:bulb: Tip:
If you use Swipe Card, you can easily include this view as part of
your Power or Network dashboard for quick UPS monitoring.

:brain: Notes & Tips

  • Delay (30 s) is important for reliable sensor updates
  • Works without NUT integration — uses only raw nc command
  • No false triggers after reconnect
  • Tested with 5-minute real outage
  • Stable 24h continuous operation

Feedback and improvements welcome — happy to answer any questions! :zap:

6 Likes

Hey, nice configuration, i was looking to get a 2U unit in the future, currently running a nice Vertiv Edge tower unit, but its not supported by NUT, only a poperitary protocol. Did you tried to add it to HA using the native NUT component? It should be supported.

Hello zolli07! Thanks!

Yes, I tried to add it using the native NUT component, but I couldn’t get it to work, and I noticed it’s not on the list of supported devices yet ( compatibility list ). Once it’s officially supported, there won’t be a need for this setup. If anyone has managed to connect it through the NUT component, please share how!

That’s exactly why I tried to extract the data differently, I wanted to see more detailed information in Home Assistant. Right now, through the UniFi Network integration, you can only see the basic stuff.

Strange, the list you linked is for the nut server compatibility (this is a standalone program that communicates with the UPS device itself), in NUT terms the client is an other standalone program (or even the HA integration) that can be installed on all machine that (typically) electrically connected to the same UPS device as the server to handle shutdown and other things, like logging.

I assume the built in server is a custom implementation of the NUT “net” protocol and sure, I found this thread where someone complaing about a bug that prevents strict clients from accessing it.

Make an eye on this issue, and add a comment with logs (if possible) to raise some eyes on this issue.

https://community.ui.com/questions/UniFi-UPS-sends-incorrect-responses-in-NUT-protocol/7f862573-eda4-4180-a987-0aca1233ee8a

Yes, I read that too. I’ll wait until the UniFi UPS 2U comes out! Maybe by then they’ll have fixed these basic issues. It seems like they’re rushing to release lots of new products and paying less attention to the software side. Right now, apart from setting a fixed IP and enabling the NUT server, there’s basically nothing you can configure. Hopefully they’ll add those missing features later on.

A bit offtopic, but yeah, typical ubiquiti relese, i’m running an unifi Intercom at my house, and it ridiculous how much improvment they push out since its released.

Hello, looks very good. Unfortunately I tried this to install, but got no further than this: Activate the ups tower in the unify app, can ping the ip-address, checked “nut server” on, added the name “ups”, kept the port to 3493, let login unchecked. Restarted the ups. Than tried from a terminal nc -vz 3493. It just returned the prompt with no response or error. Probably a stupid error of me, but cannot figure it out.
Oeps a restart from the app did not solve, but a complete power off/on did it.
Got the list, so I am getting on!

1 Like

Trying to get it working with three Home Assistant installations. Two tower ups and one rack mount ups. And in every site when i try “nc -vz IP 3493” i get resposce OPEN. But “echo -e “LIST VAR UPS\n” | nc IP 3493” i get ERR