• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

homespun/homebridge-accessory-apcupsd: An apcusbd accessory plugin for Homebridg ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

homespun/homebridge-accessory-apcupsd

开源软件地址:

https://github.com/homespun/homebridge-accessory-apcupsd

开源编程语言:

JavaScript 100.0%

开源软件介绍:

homebridge-accessory-apcupsd

An apcupsd accessory plugin for Homebridge.

Installation

Run these commands:

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

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-apcupsd

Install, Configure, and Test apcupsd

This plugin won't work until you have apcupsd 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/apcupsd/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" : "apcupsd"
, "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 apcupsd 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" : "apcupsd"
  , "name"      : "... Battery"
  , "location"  : "a.b.c.d"
  , "subtype"   : "battery"
  }
,
  { "accessory" : "apcupsd"
  , "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 apcaccess.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap