Homeassistant - Openwrt Devicetracker

计划

通过Openwrt中接入的个人电子设备wifi信号,确定相关持有人是否在家

安装

OpenWRT

  1. 确定python版本大于3.5
python -V
  1. 安装luci-mod-rpc
opkg update
opkg install luci-mod-rpc
  1. 删除uhttpd缓存
rm /tmp/luci-indexcache
  1. 检查os-release中版本号是否为数字(如果为字符会报错)
root@OpenWrt:~# cat /etc/os-release
NAME="OpenWrt"
VERSION="GDQ"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt GDQ"
VERSION_ID="18.06"  #此处若为字符或非数字,改为18.06可以通过
HOME_URL="https://openwrt.org/"
BUG_URL="https://bugs.openwrt.org/"
SUPPORT_URL="https://forum.openwrt.org/"
BUILD_ID="r4034-74b38ca2b"
OPENWRT_BOARD="x86/64"
OPENWRT_ARCH="x86_64"
OPENWRT_TAINTS="no-all override"
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt GDQ Winter[2022]"
  1. 测试是否有返回
curl http://[OpenWRT IP]/cgi-bin/luci/rpc/auth
{"id":null,"error":{"message":"Parse error.","code":-32700},"jsonrpc":"2.0"}

HomeAssistant

  1. 配置文件启动device_tracker和日志
    configuration.yaml
device_tracker:
  - platform: luci
    host: [openwrt IP]
    username: root
    password: [root password]
	
logger:
  default: debug
  logs:
    homeassistant.components.device_tracker: WARN
  1. 重启HA服务
  2. 日志在home-assistant.log中,需要检查是否有device_tracker或legacy报错
  3. 若一切正常,在config目录下会生成known_device.yaml文件,并自动在Entities中创建
  4. 绑定设备与人员
    在用户界面,将相应设备的绑定至用户即可
    image

ref: https://www.home-assistant.io/integrations/luci/

posted on 2022-08-09 20:49  BionExit  阅读(906)  评论(1编辑  收藏  举报

导航