Belkin UPS working

I’ve had some troubles with drivers for my Belkin 375VA USB UPS, not that I have tried very hard. I finally got it working today with the help of Will the intern (who rocks by the way) and only a little bit of effort, so I thought I should document it here so I know how to next time. First off, you need to install nut and nut-usb for Ubuntu (or whatever you’re using):

    $ sudo apt-get install nut nut-usb
    

Now, create a configuration entry for the USB UPS. This lives in /etc/nut/ups.conf, and mine looks like this:

    [belkinusb]
            driver = newhidups
            port = auto
            desc = "Belkin UPS, USB interface"
            vendorid=050d
    


The vendor ID here needs to match the UPS, which for my Belkin is 050d:0375. Next, you need a upsd.conf file in the same directory. Mine looks like this:

    ACL all 0.0.0.0/0
    ACL localhost 127.0.0.1/32
    
    ACCEPT localhost
    REJECT all
    

This stops hosts other than local host connecting to the daemon. Now, you need a upsd.users file, which defines what users can use the UPS:

    [admin]
            password = thisisnotthepassword
            allowfrom = 127.0.0.1
            actions = set
            instcmds = all
    

Now, start the USB UPS driver. Let’s start it in debug mode first…

    $ sudo /lib/nut/newhidups -u nut -D -a belkinusb
    
    rk UPS Tools: New USB/HID UPS driver 0.28 (2.0.3)
    
    debug level is '1'
    Detected a UPS: Belkin /Belkin UPS
    Using subdriver: Belkin HID 0.1
    Path: UPS.BELKINConfig.BELKINConfigVoltage, Type: Feature, Value: 120.000000
    Path: UPS.BELKINConfig.BELKINConfigFrequency, Type: Feature, Value: 60.000000
    Path: UPS.BELKINConfig.BELKINConfigApparentPower, Type: Feature, Value: 375.000000
    Path: UPS.BELKINConfig.BELKINConfigBatteryVoltage, Type: Feature, Value: 12.000000
    Path: UPS.BELKINDevice.BELKINModelString, Type: Feature, Value: 66.000000
    Path: UPS.BELKINDevice.BELKINModelStringOffset, Type: Feature, Value: 0.000000
    Path: UPS.BELKINDevice.BELKINUPSType, Type: Feature, Value: 1.000000
    Path: UPS.BELKINControls.BELKINTest, Type: Feature, Value: 0.000000
    Path: UPS.BELKINControls.BELKINAudibleAlarmControl, Type: Feature, Value: 2.000000
    Path: UPS.BELKINControls.BELKINDelayBeforeShutdown, Type: Feature, Value: 0.000000
    Path: UPS.BELKINControls.BELKINDelayBeforeStartup, Type: Feature, Value: 0.000000
    Path: UPS.BELKINPowerState.BELKINInput.BELKINVoltage, Type: Feature, Value: 1208.000000
    Path: UPS.BELKINPowerState.BELKINInput.BELKINFrequency, Type: Feature, Value: 599.000000
    Path: UPS.BELKINPowerState.BELKINOutput.BELKINVoltage, Type: Feature, Value: 1208.000000
    Path: UPS.BELKINPowerState.BELKINOutput.BELKINFrequency, Type: Feature, Value: 599.000000
    Path: UPS.BELKINBatterySystem.BELKINVoltage, Type: Feature, Value: 139.000000
    Path: UPS.BELKINBatterySystem.BELKINCharge, Type: Feature, Value: 100.000000
    Path: UPS.BELKINStatus.BELKINPowerStatus, Type: Feature, Value: 49152.000000
    Path: UPS.BELKINStatus.BELKINBatteryStatus, Type: Feature, Value: 16.000000
    Path: UPS.PowerSummary.iProduct, Type: Feature, Value: 20.000000
    Path: UPS.PowerSummary.iSerialNumber, Type: Feature, Value: 42.000000
    Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, Value: 68.000000
    Path: UPS.PowerSummary.iOEMInformation, Type: Feature, Value: 4.000000
    Path: UPS.PowerSummary.Rechargeable, Type: Feature, Value: 1.000000
    Path: UPS.PowerSummary.Charging, Type: Input, Value: 1.000000
    Path: UPS.PowerSummary.Charging, Type: Feature, Value: 1.000000
    Path: UPS.PowerSummary.Discharging, Type: Input, Value: 0.000000
    Path: UPS.PowerSummary.Discharging, Type: Feature, Value: 0.000000
    Path: UPS.PowerSummary.ConfigVoltage, Type: Feature, Value: 12.000000
    Path: UPS.PowerSummary.Voltage, Type: Feature, Value: 1208.000000
    Path: UPS.PowerSummary.Current, Type: Feature, Value: 0.000000
    Path: UPS.PowerSummary.CapacityMode, Type: Feature, Value: 2.000000
    Path: UPS.PowerSummary.RemainingCapacity, Type: Input, Value: 100.000000
    Path: UPS.PowerSummary.RemainingCapacity, Type: Feature, Value: 100.000000
    Path: UPS.PowerSummary.RunTimeToEmpty, Type: Input, Value: 120.000000
    Path: UPS.PowerSummary.RunTimeToEmpty, Type: Feature, Value: 120.000000
    Path: UPS.PowerSummary.DesignCapacity, Type: Feature, Value: 100.000000
    Path: UPS.PowerSummary.FullChargeCapacity, Type: Feature, Value: 100.000000
    Path: UPS.PowerSummary.WarningCapacityLimit, Type: Feature, Value: 30.000000
    Path: UPS.PowerSummary.CapacityGranularity2, Type: Feature, Value: 1.000000
    Path: UPS.PowerSummary.RemainingCapacityLimit, Type: Feature, Value: 30.000000
    Path: UPS.PowerSummary.CapacityGranularity1, Type: Feature, Value: 1.000000
    Path: UPS.PowerSummary.ACPresent, Type: Feature, Value: 1.000000
    Path: UPS.PowerSummary.ACPresent, Type: Input, Value: 1.000000
    Path: UPS.PowerSummary.BelowRemainingCapacityLimit, Type: Input, Value: 0.000000
    Path: UPS.PowerSummary.BelowRemainingCapacityLimit, Type: Feature, Value: 0.000000
    Path: UPS.PowerSummary.ShutdownImminent, Type: Input, Value: 0.000000
    Path: UPS.PowerSummary.ShutdownImminent, Type: Feature, Value: 0.000000
    upsdrv_updateinfo...
    upsdrv_updateinfo...
    
    =>Got 1 HID Objects...
    upsdrv_updateinfo...
    upsdrv_updateinfo...
    upsdrv_updateinfo...
    [snip]
    

You get the idea. You can see here that it’s found the UPS, and listed a bunch of information about the USB capabilities of the device. It will then sit in a loop forever checking the status for the device. Now, let’s hit control C on that, and start it as a daemon…

    $ sudo /lib/nut/newhidups -u root -a belkinusb
    Network UPS Tools: New USB/HID UPS driver 0.28 (2.0.3)
    
    Detected a UPS: Belkin /Belkin UPS
    Using subdriver: Belkin HID 0.1
    

Next, start the NUT UPS daemon…

    $ sudo upsd
    Network UPS Tools upsd 2.0.3
    Connected to UPS [belkinusb]: newhidups-auto
    Synchronizing...done
    

Finally, you can use the command line tool to check on the state of the UPS…

    $ upscmd -l belkinusb@localhost
    Instant commands supported on UPS [belkinusb@localhost]:
    
    test.battery.start.quick - Unavailable
    test.battery.start.deep - Unavailable
    test.battery.stop - Stop the battery test
    beeper.on - Enable the UPS beeper
    beeper.off - Disable the UPS beeper
    load.off - Turn off the load immediately
    

Unfortunately, the UPS doesn’t support power cycling it’s ports (which is what I was really hoping for), it only supports powering them down, and then waiting for human intervention, which is a shame. You can still shutdown the machine gracefully when things are going flat.