Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
homebridge-accessory-apcaccess
Advanced tools
Readme
An apcupsd accessory plugin for Homebridge.
Cloned from https://www.npmjs.com/package/homebridge-accessory-apcupsd
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
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
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 apcupsd@computers.service
# systemctl start apcupsd@computers.service
# systemctl enable apcupsd@monitors.service
# systemctl start apcupsd@monitors.service
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" : "..."
}
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"
.
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.
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 to ToddGreenfield author of homebridge-nut.
FAQs
An apcaccess accessory plugin for Homebridge: https://github.com/nfarina/homebridge
The npm package homebridge-accessory-apcaccess receives a total of 0 weekly downloads. As such, homebridge-accessory-apcaccess popularity was classified as not popular.
We found that homebridge-accessory-apcaccess demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.