npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-accessory-apcaccess

v0.13.7

Published

An apcaccess accessory plugin for Homebridge: https://github.com/nfarina/homebridge

Downloads

23

Readme

homebridge-accessory-apcaccess

An apcupsd accessory plugin for Homebridge.

Cloned from https://www.npmjs.com/package/homebridge-accessory-apcupsd

Installation

Run these commands:

% sudo npm install -g homebridge
% sudo npm install -g homebridge-accessory-apcaccess

NB: If you install homebridge like this:

sudo npm install -g --unsafe-perm homebridge

Then all subsequent installations must be like this:

sudo npm install -g --unsafe-perm homebridge-accessory-apcaccess

Install, Configure, and Test apcupsd

This plugin won't work until you have apcaccess running in your network. I found this tutorial enlightening.

If you are running homebridge on a different platform than apcupsd, then you must edit /etc/apcaccess/apcupsd.conf and change

NISIP 127.0.0.1

to

NISIP 0.0.0.0

By default, the apcupsd server will listen on

NISPORT 3551

Also make sure you have

NETSERVER on

Monitoring Multiple UPS Devices

By default, a single UPS is monitored via the USB cable; however, you can monitor multiple UPS devices on the same platform, but the configuration depends on the platform. For example, using the Debian instructions on my system:

 # lsusb
Bus 001 Device 006: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
...
 
# udevadm info --attribute-walk --name=/dev/usb/hiddev0 | egrep 'manufacturer|product|serial'
ATTRS{manufacturer}=="American Power Conversion"
ATTRS{product}=="Back-UPS RS 1500G FW:865.L7 .D USB FW:L7 "
ATTRS{serial}=="4B1848P19501  "
...

# udevadm info --attribute-walk --name=/dev/usb/hiddev1 | egrep 'manufacturer|product|serial'
ATTRS{manufacturer}=="American Power Conversion"
ATTRS{product}=="Back-UPS RS 1500MS FW:952.e3 .D USB FW:e3     "
ATTRS{serial}=="3B1812X23721  "
...

# cat >> /etc/udev/rules.d/ups.rules <<EOF
KERNEL=="hiddev*", ATTRS{manufacturer}=="American Power Conversion", ATTRS{serial}=="3B1812X23721  ", OWNER="root", SYMLINK+="usb/ups-computers"
KERNEL=="hiddev*", ATTRS{manufacturer}=="American Power Conversion", ATTRS{serial}=="4B1848P19501  ", OWNER="root", SYMLINK+="usb/ups-monitors"
EOF

# udevadm trigger --verbose --sysname-match=hiddev*

# cd /etc/apcupsd
# mv apcupsd.conf apcupsd.conf.old
# cp apcupsd.conf.old apcupsd-computers.conf
# cp apcupsd.conf.old apcupsd-monitors.conf

# vi apcupsd-computers.conf
  ... change UPSNAME to computers
  ... change DEVICE to /dev/usb/ups-computers
  ... change EVENTSFILE to /var/log/apcupsd-computers.events
  ... change SCRIPTDIR ... (if set)
  ... change PWRFAILDIR ... (if set)
  ... change STATFILE ... (if set)

# vi apcupsd-monitors.conf
  ... change UPSNAME to monitors
  ... change DEVICE to /dev/usb/ups-monitors
  ... change EVENTSFILE to /var/log/apcupsd-monitors.events
  ... change SCRIPTDIR ... (if set)
  ... change PWRFAILDIR ... (if set)
  ... change STATFILE ... (if set)
  ... change NISPORT to 3552

The change to NISPORT is very important as it will change the port number that the instance listens on.

The tricky part is to have apcupsd invoked properly by whaterver system control facility you are using.

My system uses systemctl:

# cp /lib/systemd/system
# mv apcupsd.service apcupsd.service.old
# cat > apcupsd\@.service <<EOF
[Unit]
Description=UPS '%I' power management daemon
Documentation=man:apcupsd(8)

[Service]
ExecStartPre=/lib/apcupsd/prestart
ExecStart=/sbin/apcupsd -f /etc/apcupsd/apcupsd-%i.conf -P /var/run/apcupsd-%i.pid
Type=forking
KillMode=process
PIDFile=/var/run/apcupsd-%i.pid

[Install]
WantedBy=multi-user.target
EOF

# systemctl enable [email protected]
# systemctl start [email protected]

# systemctl enable [email protected]
# systemctl start [email protected]

Configuration

Edit ~/.homebridge/config.json, inside "accessories": [ ... ] add:

{ "accessory" : "apcaccess"
, "name"      : "..."
, "location"  : "a.b.c.d"

// optional, here are the defaults
, "subtype"   : "battery"
, "options"   : { "ttl": 600, "verboseP" : false }

, "model"     : "..."
, "serialNo"  : "..."
, "firmware"  : "..."
}

Location

The IP address ("a.b.c.d") is where apcaccess is running. The default port number is 3551, and can be changed by adding it to the location value, e.g., "192.168.1.109:3552".

Subtype

By default, the plugin will report on the battery in the UPS (i.e., "subtype" : "battery"); however, you can also have it report on the power instead (i.e., "subtype" : "power").

If you want both reports, create two accessories different values for name (obviously!), but with the same location value:

  { "accessory" : "apcaccess"
  , "name"      : "... Battery"
  , "location"  : "a.b.c.d"
  , "subtype"   : "battery"
  }
,
  { "accessory" : "apcaccess"
  , "name"      : "... Power"
  , "location"  : "a.b.c.d"
  , "subtype"   : "power"
  }

Please note that the power subtype is experimental. At present, there's no mechanism to get Volt-Amperes from the UPS (0 is always reported). More importantly, Kilowatt-Hours is based on sampling Watt-Seconds.

Name, Model, Serial Number, and Firmware Revision

Although the plugin successfully retrieves these values from apcusbd, the plugin can not provide the modified values. A PR has been submitted with a possible fix. Until then, I suggest you run

% apcaccess

and add the values for UPSNAME, MODEL, SERIALNO, and FIRMWARE to the config.json file.

Many Thanks

Many thanks to ToddGreenfield author of homebridge-nut.

Many thanks to mapero author of apcupsd.