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.

How-To: presence detection using a Raspberry Pi 3 and a bluetooth phone/tag

You need:
  • Raspberry Pi 3 (or lower with Bluetooth 4.0 usb plug)
  • Phone or Tag with Bluetooth (always on..)
  • Homey with HTTP app
How:
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-requests
With 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.py
Hopefully 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

Sign In or Register to comment.