I wanted to setup an LXC Container to support 3 different UPS devices that control different systems. The end goal was to monitor these in Home Assistant for notifications and easy review. I ran into some issues and I'm sure there are better ways to do this but this is what I found worked. Network UPS Tools (NUT) configuration credit goes to: https://www.kreaweb.be/diy-home-server-2021-software-proxmox-ups/#a_Create_LXC_container
I created an LXC Container using the following settings:
ubuntu-22.04
Privileged - true
You need to find the Bus and Device # of the APC USB in order to passthrough to the container.
On the proxmox host, run:
Log the Bus # and Device #.
In my case it was "Bus 001 Device 013"
In LXC settings, go to resources and click "Add" -> "Device Passthrough" and enter the path by including the bus and device number from the host console.
Using the template: "/dev/bus/usb/{BUS#}/{Device#}" enter the bus and device from the host. In my case it was: "/dev/bus/usb/001/013"
Start the container and log in as root.
Run the following commands:
After the install completes, run the nut-scanner command to output the UPS info and confirm that that USB passthrough is working correctly:
Next, setup the configuration files. Here is the bare minimum needed for this to work:
Save the changes and run this command to check the config:
Mine returned the error:
I found that adding nut to the root group resolved it. I'm sure there are more elegant ways to do this but I could not find any.
Re-running this command again showed a successful connection without error:
Continue setting up the nut configuration.
After that, reboot container.
Running this command should return battery details. Use the template {APCNAME}@{MACHINENAME} where the {APCNAME} comes from the name used in ups.config.
upsc apc@localhost
That should return details from the UPS. To add multiple, just include those in the container passthrough devices and edit the config to include the additional UPS details.
Hopefully this helps someone else but I'm no expert here and I'm open to any feedback!
I created an LXC Container using the following settings:
ubuntu-22.04
Privileged - true
You need to find the Bus and Device # of the APC USB in order to passthrough to the container.
On the proxmox host, run:
lsusb
Log the Bus # and Device #.
In my case it was "Bus 001 Device 013"
In LXC settings, go to resources and click "Add" -> "Device Passthrough" and enter the path by including the bus and device number from the host console.
Using the template: "/dev/bus/usb/{BUS#}/{Device#}" enter the bus and device from the host. In my case it was: "/dev/bus/usb/001/013"
Start the container and log in as root.
Run the following commands:
apt-get update
apt-get upgrade
apt install nut -y
After the install completes, run the nut-scanner command to output the UPS info and confirm that that USB passthrough is working correctly:
nut-scanner -U
Next, setup the configuration files. Here is the bare minimum needed for this to work:
nano /etc/nut/nut.conf
MODE=netserver
Using info from nut-scanner -U, highlighted in bold:nano /etc/nut/ups.conf
pollinterval = 15
maxretry = 3
[apc]
# APC Back-UPS
#nut-scanner: Enter the driver name
driver = usbhid-ups
port = auto
desc = "APC Back-UPS"
#nut-scanner: Enter the vendorid, productid, and serial from the output
vendorid = 051D
productid = 0002
serial = xxxxxxxxxxxx
Save the changes and run this command to check the config:
upsdrvctl start
Mine returned the error:
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
No matching HID UPS found
Driver failed to start (exit status=1)
I found that adding nut to the root group resolved it. I'm sure there are more elegant ways to do this but I could not find any.
adduser nut root
Re-running this command again showed a successful connection without error:
upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Using subdriver: APC HID 0.96
Continue setting up the nut configuration.
nano /etc/nut/upsd.conf
LISTEN 0.0.0.0 3493
LISTEN :: 3493
nano /etc/nut/upsd.users
[upsadmin]
# Administrative user
password = ********
actions = SET
actions = FSD
instcmds = ALL
upsmon master
[upsuser]
# Normal user
password = ********
upsmon slave
After that, reboot container.
Running this command should return battery details. Use the template {APCNAME}@{MACHINENAME} where the {APCNAME} comes from the name used in ups.config.
upsc apc@localhost
That should return details from the UPS. To add multiple, just include those in the container passthrough devices and edit the config to include the additional UPS details.
Hopefully this helps someone else but I'm no expert here and I'm open to any feedback!