Sep 4, 2014

Configuring our UPS in Gentoo

If we have an UPS with a communication link (serial or usb), it can be configured in Linux with Network UPS Tools (or NUT).


You need to install the sys-power/nut package. If your UPS has an USB interface, make sure you install it with the usb flag.


Once installed, visit and go to the Compatibility List. There you can filter your UPS Manufacturer to check the NUT driver you will be using. If your Manufacturer appears but your Device Model doesn't you can try to use the same driver as any other model like the one you have. In my case I have a PowerWalker VI 650 LCD that doesn't appear on the list, but since other models of PowerWalker are using the blazer_ser and blazer_usb drivers, I'm going to use the blazer_usb driver for this one.

Edit the configuration file /etc/nut/ups.conf to add the configuration of your UPS, mine is as follows:
 driver = blazer_usb
 port = auto
 desc = "PowerWalker VI 650"

Then you can try if NUT can find your UPS by running the upsdrvctl command:
# upsdrvctl start
Network UPS Tools - UPS driver controller 2.6.5
Network UPS Tools - Megatec/Q1 protocol USB driver 0.09 (2.6.5)
Supported UPS detected with mustek protocol
Vendor information unavailable
No values provided for battery high/low voltages in ups.conf

Using 'guestimation' (low: 10.400000, high: 13.000000)!
Battery runtime will not be calculated (runtimecal not set)
If the command runs without errors, you have your UPS successfully detected by NUT. Some drivers as the blazer_usb, will require extra commands to provide the battery charge and autonomy values.

Last step is configure an administration user name in /etc/nut/upsd.user. Once that is done, you can start the daemon and if you don't get any error, add it also to your runlevel.
# /etc/init.d/upsd start
 * Starting upsd ...
fopen /var/lib/nut/ No such file or directory
listening on port 3493
not listening on ::1 port 3493
Connected to UPS [PowerWalker]: blazer_usb-PowerWalker
# rc-update add upsd
 * service upsd added to runlevel default


Once we have the daemon started, we can monitor the UPS with the upsc command. This command requires the name we gave the UPS in the /etc/nut/ups.conf file and will give us all the information about our newly-installed UPS:
# upsc PowerWalker
battery.charge: 100
battery.voltage: 13.50
battery.voltage.high: 13.00
battery.voltage.low: 10.40
battery.voltage.nominal: 12.0
device.type: ups blazer_usb
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.version: 2.6.5
driver.version.internal: 0.09
input.current.nominal: 2.0
input.frequency: 50.1
input.frequency.nominal: 50
input.voltage: 231.5
input.voltage.fault: 231.5
input.voltage.nominal: 230
output.voltage: 231.5
ups.beeper.status: disabled
ups.delay.shutdown: 30
ups.delay.start: 180
ups.load: 9
ups.productid: 5161
ups.status: OL
ups.type: offline / line interactive
ups.vendorid: 0665