跳至正文

APC UPS通过NUT转换网络UPS

为了群晖的磁盘安全,减少断电等情况导致的硬盘损坏。购入了施耐德的UPS,型号是BK650M2。先前一直是连接在群晖的USB口来进行UPS的数据读取,以及获取状态等。但是因为UPS是给整个机箱供电的,里面还有其他几个设备。所以感觉单单接在群晖上面不合适。

另外最近全屋也接入了HomeAssistant。UPS 本身有Load 和 Max power的参数。负载百分比*最大功率 就能得出我们目前的实时功耗。很方便。

所以就研究了下在Openwrt 中通过NUT(Network UPS Tools)来把我么的UPS 数据转为网络UPS

配置

Openwrt 安装需要的驱动以及应用。

shell
opkg install nut nut-common nut-driver-usbhid-ups nut-server nut-upsc

之后进行配置文件的编辑 /etc/config/nut_server,添加UPS的支持

config driver 'apc'
<h1>APC BK650 is compatible with the usbhid driver</h1>
option driver usbhid-ups
<h1>auto detect USB port</h1>
option port auto

config listen_address
   option address 0.0.0.0

config upsd upsd

之后重启upsd服务

shell
/etc/init.d/nut-server reload

查看UPS信息,可以看到UPS 的USB设备了

[email protected]:~# lsusb
Bus 001 Device 026: ID 051d:0002 American Power Conversion Back-UPS BK650M2-CH FW:294803G -292803G
Bus 002 Device 001: ID 1d6b:0003 Linux 5.15.53 xhci-hcd xHCI Host Controller
Bus 004 Device 001: ID 1d6b:0003 Linux 5.15.53 vhci_hcd USB/IP Virtual Host Controller
Bus 001 Device 001: ID 1d6b:0002 Linux 5.15.53 xhci-hcd xHCI Host Controller
Bus 003 Device 001: ID 1d6b:0002 Linux 5.15.53 vhci_hcd USB/IP Virtual Host Controller

使用 upsc命令查看当前的UPS状态。

[email protected]:~# upsc
Error: invalid UPS definition.
Required format: upsname[@hostname[:port]]
[email protected]:~# upsc apc
battery.charge: 100
battery.charge.low: 1
battery.mfr.date: 2001/01/01
battery.runtime: 2605
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 13.5
battery.voltage.nominal: 12.0
device.mfr: American Power Conversion
device.model: Back-UPS BK650M2-CH
device.serial: 000000000000
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: APC HID 0.96
driver.version.internal: 0.41
input.sensitivity: low
input.transfer.high: 278
input.transfer.low: 160
input.voltage: 226.0
input.voltage.nominal: 220
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 294803G -292803G
ups.load: 15
ups.mfr: American Power Conversion
ups.mfr.date: not set
ups.model: Back-UPS BK650M2-CH
ups.productid: 0002
ups.realpower.nominal: 390
ups.serial: 000000000000
ups.status: OL
ups.test.result: Done and passed
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d

而后在HA 中添加 NUT 的设备就OK了

标签:
%d 博主赞过: