Friday, July 8, 2016

Raspberry Pi 3 + Cisco Spark - My home presence check

Just got my Raspberry Pi 3 a few days ago.  I know there are loads of projects that I can do with that, before knowing what I actually want to do, I want to try something quick and simple to keep the box warm.  I've an python scripts based on the post here:

I modified it slightly to send a message to a Spark room when the Raspberry Pi detects my iPhone bluetooth mac address:


import bluetooth
import time
import pyCiscoSpark

print "Home Attendance"

accesstoken="Bearer "

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)
                print "Danny: out"
                resp_dict = pyCiscoSpark.post_message(accesstoken,roomid,"BT: Danny is NOT at home now - " + currenttime)


Replace ff:ff:ff:ff:ff:ff with your phone Bluetooth mac address.  I've also used the in Github for posting a message to the Spark room:

So this is how it looks like when the script is running:

Spark room:

No comments: