Turn on Bluetooth on mobile device and run bluetooth scan on raspberry pi.
hcitool scan
hcitool cc <BT MAC>
hcitool auth <BT MAC>
Create the following script and add it to /etc/rc.local
.
#!/bin/bash
MACS=(
AA:AA:AA:AA:AA:AA
)
while true; do
athome=0
for MAC in "${MACS[@]}"; do
name=`sudo hcitool name $MAC`
if ! [ -z $name ]; then
athome=1
fi
done
if [ $athome = 1 ]; then
sudo service motion stop
elif [ $athome = 0 ]; then
sudo service motion start
fi
sleep 30
done