Difference between revisions of "Home Assistant - NUT UPS Energy Tracking"
(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...") |
|||
Line 1: | Line 1: | ||
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. | 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 | + | == Network UPS Tools == |
+ | |||
+ | === Install Network UPS Tools === | ||
Network UPS Tools also called NUT is the tool we run on Linux to track UPS features. | Network UPS Tools also called NUT is the tool we run on Linux to track UPS features. | ||
sudo apt update | sudo apt update | ||
sudo apt install nut | sudo apt install nut | ||
− | == Edit /etc/nut/nut.conf == | + | === Edit /etc/nut/nut.conf === |
The default mode is none, so lets change it to standalone in this file | The default mode is none, so lets change it to standalone in this file | ||
MODE=standalone | MODE=standalone | ||
− | == Edit /etc/nut/ups.conf == | + | === 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. | 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] | [cyberpowerb] | ||
Line 21: | Line 23: | ||
vendorid = 0764 | vendorid = 0764 | ||
− | == Edit /etc/nut/upsd.conf == | + | === 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. | 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 192.168.1.100 3493 | ||
LISTEN 127.0.0.1 3493 | LISTEN 127.0.0.1 3493 | ||
− | == Edit /etc/nut/upsd.users == | + | === Edit /etc/nut/upsd.users === |
Add this to create a user that can read UPS stats. | Add this to create a user that can read UPS stats. | ||
[local_mon] | [local_mon] | ||
Line 32: | Line 34: | ||
upsmon master | upsmon master | ||
− | == Edit /etc/nut/upsmon.conf == | + | === Edit /etc/nut/upsmon.conf === |
Add your UPS to the bottom to be monitored | Add your UPS to the bottom to be monitored | ||
MONITOR cyberpowerb@localhost 1 local_mon mysupersecretpass master | MONITOR cyberpowerb@localhost 1 local_mon mysupersecretpass master | ||
− | ( | + | (optional) You may want to change polling to be less frequent |
POLLFREQ 15 | POLLFREQ 15 | ||
Line 44: | Line 46: | ||
(optional) I stopped the computer from turning off the UPS on reboot by adding "no" or anything else to the end | (optional) I stopped the computer from turning off the UPS on reboot by adding "no" or anything else to the end | ||
POWERDOWNFLAG /etc/killpowerno | POWERDOWNFLAG /etc/killpowerno | ||
+ | |||
+ | === Restart NUT Services === | ||
+ | This is for systemctl based distros of course. | ||
+ | systemctl restart nut-driver | ||
+ | systemctl restart nut-server | ||
+ | systemctl restart nut-monitor | ||
+ | |||
+ | === Query NUT Server for info === | ||
+ | This will poll the ups for available monitoring stuff. | ||
+ | upsc cyberpowerb@localhost | ||
+ | |||
+ | == Add UPS to Home Assistant == |
Revision as of 18:30, 24 October 2021
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.
Contents
Network UPS Tools
Install Network UPS Tools
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
(optional) 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
Restart NUT Services
This is for systemctl based distros of course.
systemctl restart nut-driver systemctl restart nut-server systemctl restart nut-monitor
Query NUT Server for info
This will poll the ups for available monitoring stuff.
upsc cyberpowerb@localhost