Some non-portable home monitoring, or what else you can build a trolleybus from

KDPV © Borya_Spec (facebook.com/strangedrawings)
KDPV © Borya_Spec (facebook.com/strangedrawings)

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 , , , , .





Kingston MLWG2 without top cover (photo from openwrt.org)
Kingston MLWG2 ( openwrt.org)

( ) - , , /, . , , : , . , , , , , JST ZH 5-pin.





Top to bottom: JST GH 1.25mm, JST ZH 1.50mm, original connector and battery
: JST GH 1.25 , JST ZH 1.50 ,
Thermistor replaced with 10k ohm resistor
10

, : - , - . 10 , . JST- "", 10 - , .





Ready-made bundle connector - converter
-

4 , 5 . , DSN-MINI-360 (360 - 360° ). , 4 ( , , , ). , 100% . - . ( ). .





From 4 volts without load dropped to 3.86 under load
4 3.86

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
      
      



, , … . WiFi, Ethernet, .





- UART. USB-to-TTL , ( PuTTY), (COMx:57600,8,n,1).





White - TX (R converter), green - RX (T converter), black - GND, soldered with trembling hands
- TX (R ), - RX (T ), - GND,

, , . 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 . , .





Far from a complete set of entities that can be drawn from a demon
,

, , , , , , USB-to-TTL , , - . , , Lovelace . .





Data is somewhat distorted due to testing




All Articles