http://www.instructables.com/id/Raspberry-Pi-Bluetooth-InOut-Board-or-Whos-Hom/
I modified it slightly to send a message to a Spark room when the Raspberry Pi detects my iPhone bluetooth mac address:
#!/usr/bin/python
import bluetooth
import time
import pyCiscoSpark
print "Home Attendance"
accesstoken="Bearer
roomid="
while True:
currenttime=time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
print "Checking " + currenttime
result = bluetooth.lookup_name('ff:ff:ff:ff:ff:ff', timeout=5)
if (result != None):
print "Danny: in"
resp_dict = pyCiscoSpark.post_message(accesstoken,roomid,"BT: Danny is at home now - " + currenttime)
#print (resp_dict)
else:
print "Danny: out"
resp_dict = pyCiscoSpark.post_message(accesstoken,roomid,"BT: Danny is NOT at home now - " + currenttime)
time.sleep(60)
Replace ff:ff:ff:ff:ff:ff with your phone Bluetooth mac address. I've also used the pyCiscoSpark.py in Github for posting a message to the Spark room:
https://github.com/brbester/pyCiscoSpark
So this is how it looks like when the script is running:
Spark room:
No comments:
Post a Comment