Jump to content

MyQ control with Network resource and Pi


xKing

Recommended Posts

Hi guys!

 

My Garage opener broke (little gear on top sheared off) and I had to get a replacement, so I've got one of these Chamberlain models with MyQ and no way to control it via the normal contact closure. I know about soldering to the spare visor remote button but thought I'l try the software way first.

 

So there is the simple python script that meant to be placed to /usr/lib/cgi-bin on your Pi (don't forget to do chmod +x) and called from ISY like this:

 

To close:

http://1.1.1.1/cgi-bin/myq-cgi.py?user=user@example.com&pass=secret1&cmd=close

To open:

http://1.1.1.1/cgi-bin/myq-cgi.py?user=user@example.com&pass=secret1&cmd=open

If you want to test the script:

http://1.1.1.1/cgi-bin/myq-cgi.py?user=user@example.com&pass=secret1&cmd=status

It currently does not support 2 openers on the same account but that is fairly easy to add if there is a demand for it (I have a 2 car garage but it's only one door).

 

Script is based on this one

 

Many thanks to this topic for API description and a sample code, all I had to do is to re-write it in Python.

 

My script does save a token to the temporary file and it would re-use that token within 1 hour of it's creation or until authentication fails (whatever comes first).

 

Please let me know if you are interested in supporting multiple openers and Happy 4th! :)

 

P.S. I think I can re-write it as a Node Server as well, but wondering what would be the best way to update the door status? Pulling it like every 15 minutes? I read my own door status via DSCLinc (just as a zone) so I did not add anything like that into the current version of this script.

myq-cgi.zip

Link to comment

Does it require cloud connectivity to work?

Yes, it talks to the MyQ cloud server. I know it's kind of odd to go to the cloud to close your own garage door, but MyQ Internet gateway does not seem to have anything locally accessible.

 

If you don't want could - your only way would be soldering to the remote or wall button :(

Link to comment
  • 2 months later...

Thank you xKing for the myq script.

 

In order to update the garage door status, I use ISY network resource to initiate an update, instead of polling. Basically, ISY will call a network resource, that will initiate your script, pull the status and update an ISY variable. Can ISY do the same thing with node server, eliminating the need to poll?

 

here's my script, exposed as a network resource:

#!/bin/bash

echo "Content-Type: text/html"
echo ""
echo "<!DOCTYPE html><html><body>"
ga=$(curl -s "http://rpi/automation/myq.cgi?user=MYQUSER&pass=MYQPASS&cmd=status" | grep Status | awk '{print $3;}')
echo "updating ISY with status $ga<br />"
curl -u ISYUSER:ISYPASS http://isy/rest/vars/set/1/VAR/$ga
echo "</body></html>"

Link to comment

eyaniv, thank you for your feedback!

 

Unfortunately I'm not aware of a way to "subscribe" to MyQ so I can have an always up to date status.

 

There is what I can do:

1) Have the script update ISY automatically when you invoke "status" - that would eliminate the need for the bash script.

2) Re-write it as a "server" in NODE.JS so it would run all the time and poll the MyQ server periodically (with configurable interval) and update ISY when needed (update won't be instant of course).

 

Node server would be similar to option 2, but with the same limitation - I'm not aware of the way to "subscribe" to the MyQ. I personally have a magnetic contact on my garage door tied to my security system so I know door status from it instantly.

Link to comment

Could that be 'wiresharked' if connected the local WLAN?

Probably not very easily... The api is served over SSL. I'm going to try using an intercepting SSL forward proxy to see if I can see what's going on, but if the app uses certificate pinning this will fail.
Link to comment
  • 2 months later...

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...