I have one of these garage door openers from Craftsman/Liftmaster that has an internet gateway module. As far as I know, there is no API or anything available to interface with this directly. It is, however, controllable through an https web page. Does anyone know how I could possibly mimic a login to this secure page, and then issue commands to open/close the doors from EG? In the past, I looked at some python projects like Scapy or Mechanize - and another one I found that looks super interesting (spynner), but otherwise, I'm pretty clueless. I had thought about using something like wireshark to reverse engineer the communications directly to the gateway module, but I'm sure there is probably some kind of rolling code or something to their servers. (Not positive of this, but I wouldn't know for sure until I sniffed those communications a few times). I was leaning towards integrating with the web interface anyways, as I have a Bryant thermostat that works the same way - so if I could figure it out, I could apply it there as well.
Also, most of these packages, like spynner, require quite a few dependencies and installation procedures that I am having a hard time understanding. For example, spynner says to install, you run the command "easy_install spynner" - when I open the python shell in EG, and type this, it not only thinks I'm smoking crack, it knows it. Anyways... total newb here, and I'm hoping one of you more advanced developers can get me at least started on how to install some of these other libraries so I can play around.
Thanks for any input you might have.
I'm actually working on figuring out this exact thing.
I do think that Spynner is going to be our best bet for this. The trick is getting that installed to where EG can make use of it. (But really, installing and using Spynner looks like a real challenge as well!)
I found these instructions for a different package in another post, that might work for Spynner - but it's kind of a long shot.
Install Python 2.6
Copy or move all files from python26/Lib/site-packages to the EventGhost/lib26/site-packages.
Let me know what you think...
Well, made a little progress on this. Not quite the exact direction I want to go long term here, but this might be helpful for folks who want to at least get events when the doors open or close. I don't have a way to control them yet. As a disclaimer, there are probably about 400 other ways this could have been done, and I'm betting most of them would have been easier / more robust.
OK - so here are the steps.
1. Get a GMail account if you don't already have one. It does not appear that craftsman allows you to change your email address once you register your internet gateway - I fortunately happened to register with my gmail account. I'm guessing you'd have to reregister with a gmail account if you did not do so initially.
2. In GMail:
A. create a label - I called mine "Alerts"
B. in gmail settings/filters/create a filter - enter "AssureLink Alert" in the subject line, hit create in the bottom right hand corner, then select "Skip Inbox" and "Apply the label" - selecting the label you created in 2A
C. be sure to have IMAP enabled
3. Log into your assurelink account online, create email alerts for all of your doors.
Whenever this script runs (you'll have to schedule it to run every X number of seconds or whatever - as we are polling) - it will generate an event from all the outstanding emails that are marked not read, and then mark them read.
Code: Select all
import urllib2 as req import HTMLParser import re import imaplib h = HTMLParser.HTMLParser() # ----------------- USER SECTION ----------------- # login data realm = 'New mail feed' #I don't think this one should be changed url = 'https://mail.google.com' user = 'email@example.com' passwd = 'yourgmailpassword' alertlabel = 'Alerts' #Set this to the label you have configured in Gmail # feed url feed_url = 'https://mail.google.com/mail/feed/atom/' + alertlabel # codec for subjects # for available codecs visit http://docs.python.org/2/library/codecs.html#standard-encodings codec = 'latin_1' # -------------- END OF USER SECTION -------------- # authentication auth_handler = req.HTTPBasicAuthHandler() auth_handler.add_password( realm, url, user, passwd ) opener = req.build_opener(auth_handler) req.install_opener(opener) request=opener.open(feed_url) response=str(request.read()) # find beginning and end of unread mail count # by finding the two instances of the word 'fullcount' fc_start = response.find('fullcount')+10 fc_end = response.find('fullcount',fc_start+1)-2 unread_count = response[fc_start:fc_end] if unread_count != '0': titles = ; links=['gmail.com']; ti_start=0; ti_end=0; en_start=0; en_end=0; for i in range (1,int(unread_count)+1): # find positions of keywords en_start = response.find('entry',en_end)+6 ti_start = response.find('title',en_start)+6 ti_end = response.find('title',ti_start+1)-2 li_start = response.find('link rel=',ti_end)+27 li_end = response.find('type=',li_start)-2 en_end = response.find('entry',en_start+1)+6 # extract subject utf8_subject = response[ti_start:ti_end] # decode subject decoded_subject = utf8_subject.decode('utf_8','ignore') # encode subject subject = decoded_subject.encode(codec,'ignore') subject = h.unescape(subject) #print subject #Parse event from email subject evtparse = re.search('AssureLink Alert: (.+) just (.+)',subject) #Generate Event from alert email eg.TriggerEvent('AssureLink.' + evtparse.group(1).replace(' ','') + '.' + evtparse.group(2).title()) #Mark all Alert Label items as read to prevent duplicate events generated obj = imaplib.IMAP4_SSL('imap.gmail.com', '993') obj.login(user, passwd) obj.select(alertlabel) typ ,data = obj.search(None,'UnSeen') obj.store(data.replace(' ',','),'+FLAGS','\Seen')
- You might want to set up an autostart script that marks all emails read before you periodically check for alerts. This will prevent a mass flood of events getting created if you don't have the script running for a while. (Just reuse code from bottom of script I posted above.
- I do not have it currently parsing the date/time, but that would probably be useful to include as a payload or something.
- I think it might be better to have the emails deleted rather than marked as read... but that's up to you.
- If we find this thing useful, probably would be best to roll it into a plugin, so that we don't have to dirty up the log with every time it polls. This should be pretty easy to do. I think Pako's network watcher plugin would be a real good starting point for something like this. (I'm a python noob)