Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MyQ control with Network resource and Pi

Featured Replies

Posted

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

Edited by xKing

Hello xKing,

 

Thanks so very much for sharing. May I include this in our Wiki?

 

With kind regards,

Michel

  • Author

Sure!

 

 

Sent from my iPhone using Tapatalk

Does it require cloud connectivity to work?

  • Author

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 :(

  • 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>"

  • Author

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.

The app (on a phone) updates very quickly when the garage opens or closes. I wonder if they use a websocket for this, and if it can be tapped into. The api does not appear to give details though.

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

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.
  • Author

you think the MyQ app subscribes to the updates? Not just polling it?..

you think the MyQ app subscribes to the updates? Not just polling it?..

I don't know. It seems to update too quickly to be polling. Maybe it's using Android device messaging though...
  • Author

Would be cool to find out :)

Like for my Nest "Node Server" I just use Firebase and getting all updates on line.

That's a shame....

Agree, but at least we can assume that myQ is capacity tested for a status hit every 10-15 seconds :)

  • 2 months later...
  • Author

It looks like MyQ changed the API a little, so there is a very quick fix in order for it to work with that new /api/v4

myqcgi.zip

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.