Skip to content

Presence Detection How?

Hanoh Haim edited this page May 23, 2019 · 1 revision

Presence detection is a key component for many apps. For example Alarm, Water meter etc

Challenges to make it right

  1. Various bugs in device_tracker modules (there are still many)

  2. The router support is limited with many issues

  3. iOS and Android devices can disable the wifi for a long time (to save battery life) and be off the grid

Solution that works for me

  1. I’ve added a custom component for all the TP-Links routers version. The official version has a few bugs that wasn’t solved yet. see tplink_v2

  2. Install dnsmask for DHCP/DNS server

  3. Not open sourced IoT devices (e.g. Chinese camera/and Xiaomi) are put under different color with black hole default gateway and DNS.

  4. Add custom component for mqtt_dnsmasq this trigger the presence of a device immediately (e.g. when you come home dnsmasq will find you first)

  5. Patch home assistance with this patch

How it works

  1. tp-links scan the wireless devices (slow). iOS are consided not at home after a long time (20 min) to solve aforementioned issue.

  2. ping - for wire devices

  3. dnsmasq - for quick detection (new DHCP request) - when new device is connected (wire/wireless)

AppDaemon

need to fire event to all apps when at_home (on/off) see here

  self.fire_event("at_home", enable="on")