Chamberlain/Liftmaster MyQ Plugin

from a bit of reading it appears that a token is good for 15 minutes, if a request is done with the current token, the expiration time is another 15 minutes. So, I’ll make a change to this

One odd thing I noticed is that while I can control the doors individually when I put them in a scene ( I have 2 ) only 1 closes…

Ok, finally had some time to try it out.

I ran into a problem with it’s [Lua] Library depends, since JSON isn’t one of the standard libs. It took me a while to work that out, so before I dove into it I made a few changes:

a) Reformatted entire code & XML to a single style/convention
b) Refactored a little to put the “base” URL into everything
c) Tweaked the error handling for when Username/Password details weren’t present
d) Used url_encode across the board “just in case”
e) Created a Localized copy of the dkjson.lua library, with a unique name, so the app can be free-standing
f) Added a bunch of [pseudo] constants for various things.

I was able to validate that it created a Lock child device, and that I can open/close my garage door with this mod.

Congrats, this is a great milestone for your efforts!

There are a bunch more things that need to be done to it, but the core is working reasonably at this time.

Changed attached.

I’m eager to test this out. Can you help me with some instruction on how to set this up please?

I am guessing;

  1. I need to upload the 6 files via “Luup files” menu
  2. I need to create a device (but I am not sure what to put in each text box).

Any help is greatly appreciated.

To load @macrho’s plugin, you upload all 6x files to Vera.
Then use:
Apps -> Develop Apps -> Create Device

In that UI, I only fill in:
Description = LiftMaster Garage Opener and;
Upnp Device Filename = D_LiftMasterOpener.xml

Then (Create Device) followed by b[/b]

Once it comes up, open it’s dialog, select the [Advanced] tab, and enter values for
Username = your MyQ email address and;
Password = your MyQ password

Another b[/b] operation, and the child Garage Door Opener device should appear

Thank you so much, @guessed!

It has been quite a bit of work and I need to do quite a bit more but at least there’s a functional prototype thanks to your help :slight_smile:

I believe the refreshTokens method is not needed as the token stays alive if it’s used within 15 minutes of being given out. Since I’m checking door status every 90 seconds (probably should be user configurable), I figure I can just check the return status and if I get a 33, I can reauthenticate.

I need to try and implement the task method so I can write messages if I can’t connect to the myQ service or if I get something unexpected back (Like from the paragraph above)

I should also probably be using getStatus instead of inspectDevices in the refreshDoors function [function method, I keep mixing them up]

I’m also thinking it should be called “MyQ Gateway”

I’m thinking it might be 80% of the way there!

[quote=“guessed, post:22, topic:180826”]Ok, finally had some time to try it out.

I ran into a problem with it’s [Lua] Library depends, since JSON isn’t one of the standard libs. It took me a while to work that out, so before I dove into it I made a few changes:

a) Reformatted entire code & XML to a single style/convention
b) Refactored a little to put the “base” URL into everything
c) Tweaked the error handling for when Username/Password details weren’t present
d) Used url_encode across the board “just in case”
e) Created a Localized copy of the dkjson.lua library, with a unique name, so the app can be free-standing
f) Added a bunch of [pseudo] constants for various things.

I was able to validate that it created a Lock child device, and that I can open/close my garage door with this mod.

Congrats, this is a great milestone for your efforts!

There are a bunch more things that need to be done to it, but the core is working reasonably at this time.

Changed attached.[/quote]

@jeff3lo - did guessed directions work for you?
This is very much a work-in-progress and my first attempt at Lua/LUUP
I plan on eventually writing detailed instructions on how to use but I think guessed covered it all

[quote=“jeff3lo, post:23, topic:180826”]I’m eager to test this out. Can you help me with some instruction on how to set this up please?

I am guessing;

  1. I need to upload the 6 files via “Luup files” menu
  2. I need to create a device (but I am not sure what to put in each text box).

Any help is greatly appreciated.[/quote]

I tried but it did not work for me on my UI5.

So I followed the steps and a new device was created, but I noticed 2 issues:

  1. The device always has “Lua startup failed”
  2. Inside the advance tab, I only saw a “username” but no “password” text box

Thanks.

Hmm, try rebooting your vera again. I had noticed that not all fields show up in the advanced tab and a reboot or two would help.

That’s my bad. I introduced some error reporting changes to give better feedback to the user. In the process, it “stops” after creating the Username field.

If you enter give it a value, save/reload, then the Password field will appear… where you can enter a value and save/reload to get it going again.

This is easy to fix.

Thanks for the tips, guys!

New observation: So I ran through the whole Create Device exercise again, and this time I kept adding new variables and after numerous tries, I was able to create a “Username” and a “Password”.

But after multiple saving/reloading, my device is still showing a “startup lua failed” and as a result, I don’t see any Child Device being created. The “Last Update” on my parent device is always empty, and “CommFailure” = 1.

For the sake of testing, I also downloaded macrho’s version (I was testing with guessed’s version earlier).

macrho, you were right. With your version, I rebooted the Vera a few times and the Username and Password text boxes magically showed up! I then entered my MyQ login (the same I put in my iPhone app).

Unfortunately, I ended up at the same place:

  1. On reboot, UI5 kept saying “startup lua failed” for the new MyQ device I created
  2. I do not see any child device created for my connected garage door

@jeff3lo: How many garage door openers do you have? How many places do you have?
Places are in the MyQ app on your phone

@guessed, I had to make a couple of changes:

anywhere where I saw:

    return false, "message"

I had to put

    return false, "message", "LiftMasterOpener"

also the json library was telling me that the decode method was a nil so I went back to the old json library I was using and it worked

Not sure how to test further

[quote=“guessed, post:24, topic:180826”]To load @macrho’s plugin, you upload all 6x files to Vera.
Then use:
Apps -> Develop Apps -> Create Device

In that UI, I only fill in:
Description = LiftMaster Garage Opener and;
Upnp Device Filename = D_LiftMasterOpener.xml

Then (Create Device) followed by b[/b]

Once it comes up, open it’s dialog, select the [Advanced] tab, and enter values for
Username = your MyQ email address and;
Password = your MyQ password

Another b[/b] operation, and the child Garage Door Opener device should appear[/quote]

pardon me, will this plugin also work with chamberlain? if so, shall i change “liftmaster” to “chamberlain” for all the 6 files. i have a chamberlain GDO (newly installed) and a MyQ gateway internet. thanks.

No need to rename anything. I was having some problems with guessed’s upload but give it a try and see if it works. Please note, this is really early on and isn’t exactly end user friendly. I’m learning as I go but I have been successful in controlling my garage doors through this

@macrho, I have a pretty “standard” setup: 1 LiftMaster GDO, and inside MyQ, I have 1 place called “Home” and 1 associated GDO called “Garage Door”. So I just have 1 of everything.

Thanks for looking into this.

@jeff3lo: I have a new version that incorporates guessed’s changes but changed the JSON
I believe this should work (85% chance) – the MyQ device [or whatever you named it] should be updated with the last time it pinged the services. There’s really no error handling built in (yet)
Give it a whirl

Thanks macrho! MyQ2.zip worked for me. Here is my observation:

  1. I uploaded the new files, and created a new device
  2. When I initially looked at the “Advance” tab, there was no Username and Password
  3. I started to reload Vera a few times, and Username showed up
  4. I put in my MyQ Username there, and continued to reload a few more times, the Password showed up
  5. I put in my MyQ Password there, and continued to reload a few more times, the Child Device “Garage Door” showed up
  6. Everything works perfectly after that (including Last Update, Open Garage Door, Close Garage Door)!

I’ve noticed after about 12 hours or so the token is no longer valid and the parent device doesn’t get updated. I have yet to code a check for an expired token, next on my list. I’ll do some research into making sure the username and password are visible upon initial reboot – I’m learning.
Excellent that it worked for you, I’ll keep plugging away on the code

Another small update, should request a new security token if one expires
Still a lot more work to do when I get the time

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules