Skip to content

Instantly share code, notes, and snippets.

@buszk
Created August 4, 2020 19:36
Show Gist options
  • Save buszk/79365941c0b19f785c0b6f55d77052b8 to your computer and use it in GitHub Desktop.
Save buszk/79365941c0b19f785c0b6f55d77052b8 to your computer and use it in GitHub Desktop.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment