All Projects → rmoesbergen → openwrt

rmoesbergen / openwrt

Licence: other
OpenWRT device tracker for Home Assistant that actually works

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to openwrt

addon-zerotier
ZeroTier One - Home Assistant Community Add-ons
Stars: ✭ 103 (+74.58%)
Mutual labels:  homeassistant
SmoothWAN
Internet bonding router with seamless failover using Speedify
Stars: ✭ 199 (+237.29%)
Mutual labels:  openwrt
ha-google-home
Home Assistant Google Home custom component
Stars: ✭ 285 (+383.05%)
Mutual labels:  homeassistant
haconfigs
My Home-Assistant configuration files
Stars: ✭ 61 (+3.39%)
Mutual labels:  homeassistant
plan44-feed
OpenWrt feed containing plan44 packages
Stars: ✭ 25 (-57.63%)
Mutual labels:  openwrt
openwrt-trojan
No description or website provided.
Stars: ✭ 45 (-23.73%)
Mutual labels:  openwrt
CloudFlare-DDNS-Script
CloudFlare-DDNS-Script Support LEDE/Openwrt with IPv4/IPv6
Stars: ✭ 40 (-32.2%)
Mutual labels:  openwrt
addon-log-viewer
Log Viewer - Home Assistant Community Add-ons
Stars: ✭ 37 (-37.29%)
Mutual labels:  homeassistant
core
Hue Emulation for Home Assistant
Stars: ✭ 193 (+227.12%)
Mutual labels:  homeassistant
solis-sensor
HomeAssistant integration for the Ginlong Solis PV Monitoring portal. This integration supports the current Platform v2.0 portal (m.ginlong.com) which supports Solis and Solarman PV inverter brands. Also supports new SolisCloud platform
Stars: ✭ 80 (+35.59%)
Mutual labels:  homeassistant
bmx7
BMX7 / SEMTOR Securely Entrusted Mesh Routing Protocol
Stars: ✭ 55 (-6.78%)
Mutual labels:  openwrt
ics calendar
Provides an ICS (icalendar) platform for the Home Assistant calendar
Stars: ✭ 54 (-8.47%)
Mutual labels:  homeassistant
gnb udp over tcp
gnb_udp_over_tcp 是一个为GNB开发的通过tcp链路中转UDP分组转发的服务
Stars: ✭ 32 (-45.76%)
Mutual labels:  openwrt
fullscreen-card
Make your Home Assistant browser fullscreen with one tap.
Stars: ✭ 23 (-61.02%)
Mutual labels:  homeassistant
home-assistant-config
My Home Assistant configuration.
Stars: ✭ 27 (-54.24%)
Mutual labels:  homeassistant
docker-wyze-bridge
RTMP/RTSP/LL-HLS bridge for Wyze cams in a docker container
Stars: ✭ 1,146 (+1842.37%)
Mutual labels:  homeassistant
home-assistant-flair
Custom component for Home Assistant Core for Flair pucks, vents, rooms, structures, and minisplits
Stars: ✭ 51 (-13.56%)
Mutual labels:  homeassistant
casa
Home Assistant setup for our home
Stars: ✭ 132 (+123.73%)
Mutual labels:  homeassistant
addon-portainer
Portainer - Home Assistant Community Add-ons
Stars: ✭ 83 (+40.68%)
Mutual labels:  homeassistant
NanoPi-R2S
自动发布 NanoPi-R2S 固件
Stars: ✭ 11 (-81.36%)
Mutual labels:  openwrt

OpenWRT Home Assistant device tracker

What's this?

I got fed up with all the Home Assistant device tracking solution for OpenWRT that just didn't work reliably, so I created my own. This little script runs on the OpenWRT device, polls the currently connected WiFi clients and updates their status in Home Assistant by calling the Home Assistant REST API. It only sends API requests on device join/leave. It handles connectivity issues with Home Assistant gracefully and ensures that device state is always in sync, even after restarts, connectivity loss, etc.

Installation

  • Log in to your OpenWRT device
  • Place presence-detector.py and settings.json somewhere persistent (I use /etc/config)
  • Make presence-detector.py executable: chmod +x presence-detector.py
  • Place the init-script from this repo's init.d directory into /etc/init.d on your device
  • Install python + deps: opkg update && opkg install python3-requests
  • Adjust settings.json to your needs (see below)
  • run 'service presence-detector enable' to enable the service at startup
  • run 'service presence-detector start', or simply reboot

Configuration

The settings file looks like this:

{
  "hass_url": "http://hassio.local:8123",
  "hass_token" : "<Home Assistant REST API Bearer Token>",
  "interfaces": ["hostapd.wlan0", "hostapd.wlan1"],
  "do_not_track": ["01:23:45:67:89:ab"],
  "params": {
    "00:00:00:00:00:00": {
      "mac": "ff:ff:ff:ff:ff:ff",
      "hostname": "Dave",
      "dev_id": "phonedave"
    }
  },
  "offline_after": 3,
  "poll_interval": 15,
  "full_sync_polls": 10,
  "ap_name": "",
  "location": "home",
  "away": "not_home",
  "debug": false
}

Some settings will need a bit of explaining:

  • hass_url: The URL to your Home Assistant device, including the port (8123 is the default Hass.io port).
  • hass_token: This is a Home Assistant 'Long-lived token'. You can create it in the HA web-ui by clicking on your user-name, then scolling all the way down to 'Long-lived tokens' and clicking 'Create Token'.
  • interfaces: This is an array of Wifi interface names to poll, prefixed with 'hostapd.' (it's the ubus service name).
  • do_not_track: This is an array of devices to ignore.
  • params: A dictionary containing additional parameters for specific devices. Those are sent together with MAC address and location name. Note here you could also override MAC and location name. For information on which keys you can add, see here.
  • offline_after: Set a device as not_home after is has been absent for this many poll intervals. Set this to 1 to immediately notify HA when a device leaves the network. Default: 3
  • poll_interval: Poll interval in seconds. Default: 15
  • full_sync_polls: Re-sync the device state of all devices every X poll intervals. This is to ensure device state is in sync, even after HA restarts, connectivity loss, or missed events. Default: 10
  • ap_name: If only one access point, leave as "". If script should run on multiple access points, give a name here, e.g. "ap1". The mac address will be prefixed by this on HA.
  • location: Custom location name to be assigned to spotted devices. Default: "home"
  • away: Custom location name to be sent when a device is no more connected. Default: "not_home"
  • debug: Enable or disable debugging (prints state information on stdout when enabled). Default: false

Logging

The program will run as a 'service' in the background and will log interesting events to syslog. You can read these events by running 'logread' on your device, or using your favorite web-ui.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].