From cc404acb2007d9c86f7df834a8ea510aa2f73fd2 Mon Sep 17 00:00:00 2001 From: mueslo Date: Fri, 9 Mar 2018 12:15:10 +0100 Subject: [PATCH] Add device_tracker.openwrt --- .../device_tracker.openwrt.markdown | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 source/_components/device_tracker.openwrt.markdown diff --git a/source/_components/device_tracker.openwrt.markdown b/source/_components/device_tracker.openwrt.markdown new file mode 100644 index 00000000000..4c319341590 --- /dev/null +++ b/source/_components/device_tracker.openwrt.markdown @@ -0,0 +1,48 @@ +--- +layout: page +title: "OpenWRT" +description: "Instructions how to integrate OpenWRT routers into Home Assistant." +date: 2018-03-09 12:00 +sidebar: true +comments: false +sharing: true +footer: true +logo: openwrt.png +ha_category: Presence Detection +ha_release: pre 0.7 +--- + +There are _multiple_ ways of integrating an OpenWRT router for presence detction. A broad distinction can be made between presence detection methods which actively scan for devices (by default every 12 seconds) and those that are notified by some external service on changes. It is essentially a problem of synchronizing states between two remote machines. + +* __active scanning__ + Scan for devices regularly. + * Advantages: + * robust on an unreliable set-up where the the router may not be reachable occasionally + * Disadvantages: + * average six-second delay between connecting and being registered as `home` + * lots of unnecessary network requests + * Examples: + * [ubus](/components/device_tracker.ubus/) + * [luci](/components/device_tracker.luci/) +* __passive/event-based__ + External services which notify Home Assistant of devices vie the [REST API endpoint](/developers/rest_api.markdown). + * Advantages: + * devices typically registered in under one second when they connect + * very few network requests + * Disadvantages: + * prone to missed events when connectivity between Home Assistant and the router is not guaranteed + * Examples: + * [openwrt_hass_devicetracker](https://github.com/mueslo/openwrt_hass_devicetracker) + * your own custom script + +### Event-based device tracker + +This can be achieved by running a simple shell script on the OpenWRT router which calls the appropriate Home Assistant service. An OpenWRT package which does this is listed above. As this method directly calls the [service API](/developers/rest_api.markdown#post-apiservicesltdomainltservice), no special configuration is necessary on the Home Assistant side, except for ensuring the device_tracker API is running, which is achieved by adding the following to your `configuration.yaml` file: + +```yaml +device_tracker: +``` + +To get the best of both worlds, you can combine the two approaches, running both a periodic device scanner and an event-based device tracker. + +See the [device tracker component page](/components/device_tracker/) for instructions how to configure the people to be tracked.