Home Assistant - NUT UPS Energy Tracking

From ETCwiki
Revision as of 18:22, 24 October 2021 by Ddxfish (talk | contribs) (Created page with "If you have a UPS (Uninterruptible Power Supply) that has either a USB connection or ethernet connection, you can likely add it to Home Assistant Server as an energy tracking...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

If you have a UPS (Uninterruptible Power Supply) that has either a USB connection or ethernet connection, you can likely add it to Home Assistant Server as an energy tracking device. This guide is generic enough to work with most USB UPS but I am using a Cyberpower CP1000, and have 2 of them showing up as an energy tracking device in my Home Assistant Energy section.

Install NUT

Network UPS Tools also called NUT is the tool we run on Linux to track UPS features.

sudo apt update
sudo apt install nut

Edit /etc/nut/nut.conf

The default mode is none, so lets change it to standalone in this file

MODE=standalone

Edit /etc/nut/ups.conf

We need to add our UPS to this file so NUT knows what driver to use. Add this section to your ups.conf. Name your ups in the square brackets, it doesn't have to say cyberpowerb, this is just mine.

[cyberpowerb]
     driver = usbhid-ups
     port = auto
     desc = "Cyberpower CP1000 B"
     pollfreq = 30

If you are having detection problems, add this line to your ups.conf config just under the driver line. Replace with your UPS vendor ID (find via lsusb)

vendorid = 0764

Edit /etc/nut/upsd.conf

Add a LISTEN directive, you can have more than one. Port separated by a space. Default is 3493. You may not want to open your LAN IP here.

LISTEN 192.168.1.100 3493
LISTEN 127.0.0.1 3493

Edit /etc/nut/upsd.users

Add this to create a user that can read UPS stats.

[local_mon]
      password = mysupersecretpass
      upsmon master

Edit /etc/nut/upsmon.conf

Add your UPS to the bottom to be monitored

MONITOR cyberpowerb@localhost 1 local_mon mysupersecretpass master

(otional) You may want to change polling to be less frequent

POLLFREQ 15

(optional) If your UPS goes stale, change when it assumes it is dead

DEADTIME 30

(optional) I stopped the computer from turning off the UPS on reboot by adding "no" or anything else to the end

POWERDOWNFLAG /etc/killpowerno