A Bluetooth presence detection written in python.
It runs fine on a Raspberry Pi Zero running Raspbian 9.8.
$ sudo apt-get install bluetooth libbluetooth-dev
git clone git@github.com:cgtobi/pypresence.git
Create virtual environment and activate it.
cd pypresence
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
Make a copy of presence.yaml.example
and edit according to your environment.
mqtt_host: 192.168.0.123
mqtt_port: 1883
mqtt_user: usermqtt
mqtt_pwd: 123
Configure timeouts and scan interval to determine how often to scan for your devices.
ble_timeout: 10
bt_timeout: 6
scan_interval: 30
For each device to be tracked add the required information.
Check the examples below.
- name : iphone
mac: '40:9F:AF:79:9F:D2'
bt_type : bt
- name: KeyTag
mac: 'EF:7F:DF:AF:ED:1F'
bt_type : ble
- name : Withings Watch
uuid: '00000012345671234556000000000000'
bt_type : ble
sudo presence.py -c presence.yaml
Copy pypresence@pi.service
to /etc/systemd/system/pypresence@pi.service
.
Enable the service and check its state.
sudo systemctl daemon-reload
sudo systemctl enable pypresence@pi.service --now
sudo systemctl status pypresence@pi.service
Check the service logs:
sudo journalctl -f -u pypresence@pi.service