So I have a Schlage LiNK Wireless Keypad Entry Lever Lock Starter Kit System*
. I am trying to take the whole thing apart call by call but until I am ready to post that I wanted a quick easy way to interface with the system in a semi cool way. Basically I wanted anyone who types the code in the door to hear “Welcome home” $First $last. So I decided that I could at least in the time being before I figure out Zwaves command classes, just check my email (Special notification Inbox) and parse the name from there. This works pretty well, I mark it as read so I don’t see it the second time around and then set it on a launchd job. Though really you could use this to run any command based on a special subject line, so its a quick easy example of something sorta cool. I have not had a chance to make a youtube video of it, but I will when its a little more sexy ( and I get the arduino hooked up to the metal skull servos, yes I am totally not joking that I have a metal skull that I am teaching to speak).
Grab the script here
#!/usr/bin/python
import imaplib
import string, random
import StringIO, rfc822
import email, sys
import os
from datetime import datetime, timedelta
import plistlib
SERVER = "mail.wallcity.org"
USER = "home"
PASSWORD = "mypassword"
lastcheck = datetime.now ()
print lastcheck
# connect to server
server = imaplib.IMAP4_SSL(SERVER)
# login
server.login(USER, PASSWORD)
server.select()
#typ, data = server.search(None, 'ALL')
typ, data = server.search(None, '(FROM "alerts@schlagelink.com")','UNSEEN')
for num in data[0].split():
resp, data = server.fetch(num, "(RFC822)")
text = data[0][1]
file = StringIO.StringIO(text)
message = rfc822.Message(file)
subject = message['Subject']
if subject == 'Schlage LiNK Alert':
#body = server.fetch(num,"(UID BODY[TEXT])")
body = server.fetch(num,"(BODY[TEXT])")
imaptolken = body[1]
bodytolken = imaptolken[0]
textbody = bodytolken[1]
words = textbody.split()
first_name = words[8]
print words
last_name = words[9]
cmd = '/usr/bin/say' + ' ' + 'Welcome home ' + first_name + ' ' + last_name
# Turn the volume up
set_volume_command='/usr/bin/osascript -e \'set volume 10\''
os.system(set_volume_command)
os.system(cmd)
server.logout()
* Please note my Amazon Link
Here is an example of what these emails look like:
