I have created a new custom device_tracker component that connects to a kismet server instance and tracks people (MACs actually). Kismet (for those who do not know it) is a wifi monitor program that puts a wifi card in monitor mode and hops around the channels listening for wifi beacons and probe requests. It can capture packets, create reports and recently has a REST API that you can query to see if MAC address AA:BB:CC:DD:EE:FF was seen around in the last 50 seconds. This is what this tracker component does.
To use it, you need a recent kismet version. Versions bundled with Ubuntu 16.04 or 18.04 are too old and donāt have the REST API. You can install it by following this guide: https://github.com/kismetwireless/kismet/blob/master/README. Youāll also need a wifi card that supports monitor mode. You can use multiple servers located at different places if needed.
Currently, the kismet device_tracker can be used as a custom component - which you can install following these steps:
$ sudo su - homeassistant
$ cd .homeassistant
$ mkdir -p custom_components/device_tracker
$ cd custom_components/device_tracker
$ wget -O kismet.py https://raw.githubusercontent.com/mad-ady/home-assistant-customizations/master/custom_components/device_tracker/kismet.py
You will need to edit configuration.yaml and add the component:
device_tracker:
- platform: kismet
interval_seconds: 30
host: 192.168.1.15
port: 2501
consider_home: 420
clients:
- 84:98:66:47:cf:aa
- d0:31:69:38:f2:99
ssids:
- DIGI
For extra debugging, you can set the component to debug inside the logger as well:
logger:
default: error
logs:
custom_components.device_tracker.kismet: debug
Once you restart the component will connect periodically to the kismet instance and query for the devices you listed. It will get results for the last āinterval_secondsā period (e.g. for the last 30 seconds), so even if the mobile device was active for a little while in that interval it will get picked up and reported. The length of interval_seconds only affects how quickly a device is seen, not whether it is seen or not.
The parameters have the following meaning:
- interval_seconds - how often to ask for updates from the kismet server
- host - the kismet server IP/FQDN (127.0.0.1 by default)
- port - the port where kismet is running (2501 by default)
- consider_home - how long should a client be still considered at home if he hasnāt been seen (7 minutes is ok for clients with wifi open, but not associated to a network. May depend from device to device)
- clients - a list of MAC addresses to look for. Can be a regular expression
- ssids - a list of SSIDs to look for. Can be a regular expression
Devices which are discovered are added to known_devices.yaml, like regular trackers.
Now, I need the communityās help to add this as a standard component inside HA. I can add the code and ask for a PR, but what repo do I need to fork for the documentation? Also, is the code written ok to be used by others? Do I need to change formatting/add more comments?
Thanks