This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
How-To: presence detection using a Raspberry Pi 3 and a bluetooth phone/tag
DieterKoblenz
Member
in Developers
You need:
I am assuming you know your way around a Raspberry Pi and don't mind a bit of fooling around For this to work you need to install the latest "bluez" library for the Pi as this handles the low level bluetooth stuff.
Install bluez:
Ofcourse you need to edit the given requests in the homeytracking.py and make sure it runs at all times. Good luck!
- Raspberry Pi 3 (or lower with Bluetooth 4.0 usb plug)
- Phone or Tag with Bluetooth (always on..)
- Homey with HTTP app
I am assuming you know your way around a Raspberry Pi and don't mind a bit of fooling around For this to work you need to install the latest "bluez" library for the Pi as this handles the low level bluetooth stuff.
Install bluez:
sudo wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.41.tar.xz sudo tar -xJf bluez-5.41.tar.xz cd bluez-5.41 sudo ./configure --disable-systemd sudo make sudo make install
Now you need to install the proper python library:
sudo apt-get install python-bluez python-requestsWith that out of the way you will need to find the MAC addresses of the tags/phones you want to track. Run the following python script with your phone bluetooth on visible (this is only needed for finding the MAC).
sudo wget https://gist.github.com/DieterKoblenz/9efca3c9b90bd851c4130fe4c4b22677/raw/ed0ba86e03c91bc44549a7b7550600cd55c87e22/findmac.py sudo python findmac.pyHopefully you will get the following output:
found 1 device
XX:XX:XX:XX:XX:XX - Phone
Copy the MAC-address as you need it for the final script.
I am using a modified version of a python tracking board I found on instructables and you can modify it easily.
https://gist.github.com/DieterKoblenz/15415aadf37dfbca2ac11759de32040c/raw/ea21233cb0fbd6f8c3b3889b5deee5644bba4931/homeytracking.py
As a final step you need to make a flow using the HTTP app. I am using a very simple GET request for presence HOME and AWAY.
Ofcourse you need to edit the given requests in the homeytracking.py and make sure it runs at all times. Good luck!
Comments
I've published new version 1.6.2 of Presence tracker app.
It is working now
Now I need a way to combine both bluetooth information with ping information.
First try running arpscan from shell. Use same args in config or remove args altogether.
Is there a way to enable more feedback? Now I feel like just doing stuff blind.
In the mean time I've cooked up a python script that uses Bluetooth first and falls back to arp-scan when it doesn't detect my phone. Combined with doing three consecutive scans before calling me "away" has resulted in no false "Left the house announcements" so far.