Contributed by tbert on 2014-03-20 from the no-breaks-for-the-wicked dept.

Andre de Oliveira (andre@) has committed the upd(4) driver, which detects uninterruptible power supplies (UPS) attached to USB, which will show up in the dmesg:

uhidev0 at uhub1 port 1 configuration 1 interface 0 "American Power Conversion Back-UPS RS 500 FW:30.j5.I USB FW:j5" rev 1.10/0.06 addr 2 uhidev0: iclass 3/0, 98 report ids upd0 at uhidev0

The UPS will then have a few sensors attached, which will show you running on battery:

% sysctl hw.sensors.upd0 hw.sensors.upd0.indicator0=Off (Charging) hw.sensors.upd0.indicator1=On (Discharging) hw.sensors.upd0.indicator2=Off (ACPresent) hw.sensors.upd0.indicator3=On (BatteryPresent) hw.sensors.upd0.indicator4=Off (ShutdownImminent) hw.sensors.upd0.percent0=100.00% (FullChargeCapacity) hw.sensors.upd0.percent1=94.00% (RemainingCapacity)

And charging:

% sysctl hw.sensors.upd0 hw.sensors.upd0.indicator0=On (Charging) hw.sensors.upd0.indicator1=Off (Discharging) hw.sensors.upd0.indicator2=On (ACPresent) hw.sensors.upd0.indicator3=On (BatteryPresent) hw.sensors.upd0.indicator4=Off (ShutdownImminent) hw.sensors.upd0.percent0=100.00% (FullChargeCapacity) hw.sensors.upd0.percent1=91.00% (RemainingCapacity)

Please note that this still requires an additional patch:

upd(4) is now enabled to be built for amd64, macppc and sparc64, thanks to mpi@ uhidev diff. still, to get it attaching correctly, these vendor/product id pairs need to be removed from usb_quirks.c. read it as: these devices won't attach to ugen anymore.

Please note that this is a new driver under active development, so your UPS may not be supported. The only way that OpenBSD will get out-of-the-box support for these devices is for as wide a variety as can be tested to get tested, so patch, build, attach, and report any and all failures to the author.

UPDATE: andre@ has made it known that this no longer requires a patch; snapshots that are built after the time of publication should have the change.