Home Assistant , , . , , , , . , , , " ". , , , , " ". , , , , , "" , - , , ?
TL;DR
, Kingston Mobilelite Wireless MLWG2 , ( , ), OpenWrt, APC UPS Home Assistant.
: , - - . , ?
Intro
, : , , "APC Back-UPS ES 700", Home Assistant, - . , , "USB-RJ45", ( , ). , , USB, - , " ", Kingston MobileLite Wireless G2. MLWG2: , , WiFi, ( ), "", . , . Apple, .
, , , . , , 24/7 , , , , .
( ) - , , /, . , , : , . , , , , , JST ZH 5-pin.
, : - , - . 10 , . JST- "", 10 - , .
4 , 5 . , DSN-MINI-360 (360 - 360° ). , 4 ( , , , ). , 100% . - . ( ). .
Kingston MLWG2 OpenWrt ( ) , 19.07.7. . - , , "" . telnet. , init- , . , FAT32, OpenWrt ( openwrt-19.07.7-ramips-mt7620-mlwg2-squashfs-sysupgrade.bin ), "mlwG2_v;telnetd; .x.x.bin" ( , ).
, WiFi-, telnet- ( admin, , ip ):
telnet 192.168.201.254
BusyBox:
(none) login: admin
BusyBox v1.12.1 (2014-09-18 09:46:08 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
#
...
mtd_write write /media/USB1/openwrt-19.07.7-ramips-mt7620-mlwg2-squashfs-sysupgrade.bin KernelA mtd_write -r write /media/USB1/openwrt-19.07.7-ramips-mt7620-mlwg2-squashfs-sysupgrade.bin KernelB
- UART. USB-to-TTL , ( PuTTY), (COMx:57600,8,n,1).
, , . eth0 - eth0.1, WiFi . , reboot, OpenWrt (UART , failsafe ).
root@OpenWrt:/etc/config# cat network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fdf0:a4ca:5192::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0.1' <--- eth0
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
config device 'lan_eth0_1_dev'
option name 'eth0.1' <-- eth0
option macaddr '00:26:b7:09:e9:32'
root@OpenWrt:/etc/config# cat wireless
config wifi-device 'radio0'
option type 'mac80211'
option channel '11'
option hwmode '11g'
option path 'platform/10180000.wmac'
option htmode 'HT20'
option disabled '1' <--
config wifi-iface 'default_radio0'
option device 'radio0'
option network 'lan'
option mode 'ap'
option ssid 'OpenWrt'
option encryption 'none'
OpenWrt , , , . , LuCI: Network -> Wireless -> Scan -> Join Network -> Assign firewall-zone = lan. , , (Mode: Master), IP (- ).
APC apcupsd, Home Assistant , , configuration.yml.
USB :
opkg update opkg install kmod-usb-hid opkg install apcupsd
, , :
root@OpenWrt:/# ls -la /dev/usb
drwxr-xr-x 2 root root 60 Mar 2 21:10 .
drwxr-xr-x 5 root root 1380 Mar 2 21:10 ..
crw------- 1 root root 180, 96 Mar 2 21:10 hiddev0
/etc/apcupsd, apcupsd.conf, . (, USB-, ):
## apcupsd.conf v1.1 ##
UPSCABLE usb
UPSTYPE usb
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
C
/etc/init.d/apcupsd start
apcaccess , STATUS: ONLINE. ( ) .
.
root@OpenWrt:/etc/apcupsd# apcaccess
APC : 001,035,0824
DATE : 2021-03-03 00:23:17 +0300
HOSTNAME : OpenWrt
VERSION : 3.14.14 (31 May 2016) unknown
UPSNAME : OpenWrt
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE :
STARTTIME: 2021-03-03 00:23:15 +0300
SHARE :
MODEL : Back-UPS ES 700
STATUS : ONLINE
LINEV : 232.0 Volts
LOADPCT : 42.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 31.4 Minutes
MBATTCHG : 10 Percent
MINTIMEL : 5 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 180.0 Volts
HITRANS : 266.0 Volts
ALARMDEL : 30 Seconds
BATTV : 13.5 Volts
LASTXFER : Low line voltage
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
...
Home Assistant
, configuration.yml, :
apcupsd:
host: <IP apcupsd>
port: 3551
sensor:
- platform: apcupsd
resources:
- bcharge
- loadpct
- status
- timeleft
- model
- linev
entities: , (ONLINE, ONBATT, ...), % , % , , ( , ). , Home Assistant - 10-40 , - 2-3 . , .
, , , , , , USB-to-TTL , , - . , , Lovelace . .
OpenWrt: https://openwrt.org/toh/kingston/mlwg2
: https://oldwiki.archive.openwrt.org/toh/kingston/mlwg2
Installing apcupsd on OpenWrt: https://openwrt.org/docs/guide-user/services/ups/apcupsd_es500
Connecting apcupsd to Home Assistant: https://community.home-assistant.io/t/how-to-connect-your-apc-ups-to-rpi-and-home-assistant-using-apcupsd/10609
A little more about connecting apcupsd: https://sprut.ai/client/blog/1646
Other: https://www.google.com