|
1 | 1 | # HAPT |
2 | 2 |
|
3 | | -Home Assistant Presence Tracker (HAPT) is an event-driven device presence tracker for [Home Assistant](https://www.home-assistant.io/) on an OpenWRT router or access point. |
| 3 | +Home Assistant Presence Tracker (HAPT) is an event-driven device presence tracker for [Home Assistant][homeassistant] on |
| 4 | +an OpenWRT router or access point. |
4 | 5 |
|
5 | 6 | ## Description |
6 | 7 |
|
7 | | -Coming soon... |
| 8 | +HAPT listens on association and disassociation events to wireless networks, using the hostapd control interface. It |
| 9 | +keeps track of which device is connected to which networks. When a device connects to its first network, or disconnects |
| 10 | +from its last network, a service call to Home Assistant is performed to mark the device as home or away. By tracking |
| 11 | +active device connections, HAPT ensures that a device switching between different networks (e.g. the 2.4 GHz and 5 GHz |
| 12 | +bands) is not marked as away. |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +### Installation |
| 17 | +Download a package from the [releases][releases] page, and install it either by uploading it in LuCi (System > Software) |
| 18 | +or running `opkg install <file>` from a shell. |
| 19 | + |
| 20 | +### Configuration |
| 21 | +Once the package is installed, you must update the configuration in `/etc/config/hapt`. At minimum the `host` option |
| 22 | +should be set to the address of your Home Assistant installation, and the `token` option to a Home Assistant |
| 23 | +[long-lived access token][token] (these can be generated in the Home Assistant web interface). |
| 24 | + |
| 25 | +The `consider_home_timeout` and `consider_home_disconnect` settings can be used to configure for how long (in seconds) |
| 26 | +after the first association and last disassociation event the device should be considered home. Since Home Assistant |
| 27 | +does not support marking a device as away (on disconnects), this is implemented by marking the device as home for a |
| 28 | +negligible amount of time, after which Home Assistant will mark the device as away. The default values should be fine |
| 29 | +here. |
| 30 | + |
| 31 | +With the `wifi_interfaces` option, it is possible to specify the wireless interfaces that must be monitored. This can be |
| 32 | +used (for example) to ignore devices on a guest network. |
| 33 | + |
| 34 | +### Running |
| 35 | +After modifying the configuration, you must restart the service by `service hapt restart`. This can also be done from |
| 36 | +the LuCi interface (System > Startup). HAPT prints log messages to the system log, so that you can verify it is working |
| 37 | +as expected. |
| 38 | + |
| 39 | +It is possible to synchronize just the currently connected devices with Home Assistant by running `hapt` from the |
| 40 | +command line. This can be especially useful to debug the connection with Home Assistant, as this will also print any |
| 41 | +errors that occur. |
| 42 | + |
| 43 | +## Development |
| 44 | +You can build a custom package by running the `makepkg.sh` script, which will run the package build in a Docker |
| 45 | +container and place the compiled package in the `build/bin` directory. |
8 | 46 |
|
9 | 47 | ## Acknowledgments |
10 | 48 |
|
11 | | -This project has been inspired by the [openwrt_hass_devicetracker](https://github.com/mueslo/openwrt_hass_devicetracker) package. |
| 49 | +This project has been inspired by the [openwrt_hass_devicetracker][hasstracker] package. |
| 50 | + |
| 51 | +[homeassistant]: https://www.home-assistant.io/ |
| 52 | +[hasstracker]: https://github.com/mueslo/openwrt_hass_devicetracker |
| 53 | +[releases]: https://github.com/oxan/hapt/releases |
| 54 | +[token]: https://www.home-assistant.io/docs/authentication/ |
0 commit comments