Detect a person with his/her smartphone entering or leaving the wireless home network.
Using the network binding does not do the job for Android and iOS based devices as these devices enter deep sleep at some point and are not pingable anymore and would appear as offline.
In my special case I need to check the devices on a Fritzbox 7490 and two DD-WRT based Atheros routers (TP-Link Archer C7, DD-WRT v3.0-r33525 std 10/17/17) I use as additional access points to cover the whole house.
For getting data from the Fritzbox I use the Fritzbox TR064 Protocol Binding which works for a bunch of different Fritzbox models.
The data from the DD-WRT devices is sent by a script and REST to openHAB. I used these howtos but needed to change some details as it was not working here.
- openHAB Fritzbox TR064 Binding zur Anwesenheitserkennung
- DD-WRT Presence Detection with ARP for openHAB
- openHAB Presence Detection with a DD-WRT Router
The main difference here is that I kicked out user and password (as this cannot be set in openHAB 2.0/2.1 at the moment) and also I changed the command which gets the MAC addresses for all online devices. wl_atheros assoclist gets all online devices from all ath wireless interfaces, which is exactly what we want here.
- ddwrt.items: Put this file into your /etc/openhab2/items directory and modify it for your specific setup.
- ddwrt.sh: Modify the content of this file for your specific setup and put it in your DD-WRT Startup Script (if you already have one please paste it under what you already have) and save it like described here and here. If you have two DD-WRT devices like me then you need to modify the script again for the second router (DDWRT1 to DDWRT2). I left two other devices in this script, but I only use the first two devices for presence detection. Leave these devices as well or remove them (then you need to change some other parts of the script, too).
- fritzboxtr064.items: Put this file into your /etc/openhab2/items directory and modify it for your specific setup. Don't forget to install/activate the fritzboxtr064 binding first and prepare the Fritzbox like described here.
- presence.items: Put this file into your /etc/openhab2/items directory and modify it for your specific setup.
- presence.map: Put this file into your /etc/openhab2/transform directory and modify it for your specific setup.
- presence.rules: Put this file into your /etc/openhab2/rules directory and modify it for your specific setup.