General > Power Management

APC UPS Backup - Now just needs a plugin

(1/15) > >>

The new Vera3 comes with an integrated battery backup, which is awesome except your modem, all your z-wave devices, wifi, etc is still going to go down.  You need a real battery backup that will stay online long enough to fire off notifications that your net is down.

I picked up an el cheapo APC UPS ES 450.  It has 4 battery backup ports and advertises 30 minutes in a power outage.  It has a funny USB to Ethernet cable (the Ethernet end hooks up to the APC), so you can control and monitor it from the Vera2/3.  However, the kernel device does not exist on the Vera and you have to install that.   You'll also need to install the monitoring daemon.   To my knowledge the Vera2 hardware is the same so you'll have to go through these steps:

1.) Log into your Vera as root.

2.) Install the USB-HID kernel object.  You don't need to compile one or anything - you can install this one that's close enough.

Here's what I did:

--- Code: ---root@MiOS_18273:/# cd /lib/modules/
root@MiOS_18273:/lib/modules/ wget "" -O hid.o.tgz
Connecting to (
hid.o.tgz            100% |*********************************************************************************************************************************************************************************************| 14293  00:00:00 ETA
root@MiOS_18273:/lib/modules/ tar xzvf hid.o.tgz
root@MiOS_18273:/lib/modules/ insmod -f hid.o
root@MiOS_18273:/lib/modules/ cat /proc/bus/usb/drivers
 [b]96-111: hiddev[/b]
root@MiOS_18273:/lib/modules/ cat /proc/bus/usb/devices | grep HID
I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=[b]hid[/b]

--- End code ---

3.) Now that the HID device is installed, we need to install the daemon

--- Code: ---opkg install ""
--- End code ---

Refer to for more info on how to interact with the device.  

4.) Modify your config file.  Its in /etc/apcupsd/apcupsd.conf
5.) Check to make sure it's running:

--- Code: ---root@MiOS_18273:/lib/modules/ apcaccess status
APC      : 001,035,0892
DATE     : Wed Sep 14 20:53:47 CDT 2011
VERSION  : 3.14.7 (1 August 2009) unknown
UPSNAME  : ups1
CABLE    : USB Cable
MODEL    : Back-UPS ES 450
UPSMODE  : Stand Alone
STARTTIME: Wed Sep 14 20:52:44 CDT 2011
LINEV    : 126.0 Volts
LOADPCT  :   0.0 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT : 126.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Medium
LOTRANS  : 092.0 Volts
HITRANS  : 139.0 Volts
BATTV    : 13.5 Volts
LASTXFER : Unacceptable line voltage changes
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
STATFLAG : 0x07000008 Status Flag
MANDATE  : 2011-04-09
SERIALNO : 3B1115X42707
BATTDATE : 2011-04-09
NOMINV   : 120 Volts
NOMBATTV :  12.0 Volts
END APC  : Wed Sep 14 20:53:49 CDT 2011

--- End code ---

If anyone wants to attempt to write the plugin with me please let me know.




--- Quote from: Kristopher on September 14, 2011, 09:56:49 pm ---If anyone wants to attempt to write the plugin with me please let me know.

--- End quote ---

Let's do it.

Although I've got one of these, it isn't in the same room as my Vera, so you'll have to be the sole tester.  (Also, I use nut, because I have multiple brands of UPS in my house.)

I propose that we start simple and make the plugin appear as an appliance switch.  On == on A/C power; Off == on battery.  Will that do for a beginning?

If your able to manually switch from mains to battery via the API then a switch makes sense.  Otherwise, if you can only detect what state it's in you might want to used LightSensor1 instead, since it's inherently read-only... And will have a correct rendition on conol points...

A lightsensor would make more sense. You can use the % value of the light sensor to show the remaining percentage left of the battery when on battery power. My vera is hooked up to a cyperpower ups in the garage which a switch is also plugged into the cyberpower as well. Is available via dd-wrt repository? I have a few apc ups, however they are used in my office which is several floors up from the vera unit.

- Garrett

The power loss detection should be event driven.

Excerpt from the excellent apcupsd manual:

--- Code: ---Apcupsd Notification and Events
When a major event is generated within apcupsd, control is passed to the script apccontrol normally found
in /etc/apcupsd/apccontrol. The event name, and a number of other important parameters are passed to
the script.

--- End code ---

I'm sure there are many other ways to get the UPS events to the Luup plugin.

In addition, the plugin could poll the current UPS status and store the UPS variables in corresponding UPnP variables.
Add Luup events to the plugin as needed.

BTW, is there an UPnP service for UPS from the UPnP Forum?


[0] Message Index

[#] Next page

Go to full version