UPower And UPS Detection Foo

Since I installed Ubuntu 11.10 I have some strange issues on my desktop machine. I have a UPS from APC which is controlled using the demon and not the GUI tools. Nonetheless my computer went randomly to sleep without any reason.

After some research I took action and removed the UPS from equation. So here is a way how to make UPower not to detect the UPS.

In the end it is pretty easy once you know that udev is the helper for UPower.

The first thing is to find out what kind of device you have. My APC is defined in the following file:

/lib/udev/rules.d/95-upower-hid.rules

In that file the APC devices are marked as UPS devices for UPower. This happens by setting the variable UPOWER_BATTERY_TYPE to ups. If that field is set to an empty string (“”) then the battery is not detected by UPower.

In order to make udev not to detect the APC UPS devices I created the following file:

/etc/udev/rules.d/99-remove-APC-ups.rules

# Rule to remove ENV data for APC UPS for upower
ATTRS{idVendor}=="051d", ENV{UPOWER_VENDOR}=""
ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0002", ENV{UPOWER_BATTERY_TYPE}=""
ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0003", ENV{UPOWER_BATTERY_TYPE}=""

After rebooting (or reconnecting the UPS) a simple upower -d shows that we don’t have a battery anymore. All is good…