Giter VIP home page Giter VIP logo

alexa-myqgarage's Introduction

Alexa-MyQGarage

Using the Alexa Skills Kit to control your Chamberlain MyQ garage door.

Description

By using the Alexa Skills Kit and AWS Lambda, you can control your Chamberlain MyQ garage door through your Amazon Echo. This code adapts David Pfeffer's unofficial Chamberlain Liftmaster API to a Python-based app you can use inside of AWS Lambda.

Usage

  1. Create an Alexa Skills Kit (ASK) app, using the intent schema, custom slot values, and sample utterances in this repo. Choose an invocation name like my garage door.

  2. Replace <MYQ_LOGIN_USERNAME> and <MYQ_LOGIN_PASSWORD> in main.py with the username and password you created at Chamberlain, and substitute amzn1.echo-sdk-ams.app.<your-alexa-skills-id> with the ID of the ASK skill you created. The APP_ID should remain the same, it is Chamberlain specific and not specific to your MyQ account.

  3. Create a zip file for Lambda with the following command (you'll need it later in step 6):

     zip -r lambda-upload.zip main.py myq.py requests requests-2.9.1.dist-info
    
  4. Create a new AWS Lambda function in the us-east-1 (N. Virginia) region. At "Select a Blueprint," press the "Next" button to skip.

  5. For the "Configure Triggers" page, click in the dotted box to show the triggers options, and select "Alexa Skills Kit." Click next to continue.

  6. Configure the function by giving it a name, description, and selecting the "Python 2.7" runtime. For "Code Entry Type," specify the ZIP file "lambda-upload.zip" that you created in Step 3.

  7. Change "Handler" to "main.lambda_handler", and use a "Create new role from templates" as your "Role".

  8. Give your role a name, like "MyQRole", and choose "Simple Microservice Permissions." Leave "Memory" and "VPC" at their defaults, and give a timeout of "15 seconds," then click "Next". A new page will open. Verify your details, then click "Create function."

  9. Modify your ASK skill with the ARN of your newly created function.

  10. Test your interactions with the ASK console. When you've got it working, try it on your Echo: Alexa, ask my garage door to open.

If this worked, congratulations! If not, keep reading!

IMPORTANT: Before attempting to troubleshoot your issue, first verify that AWS Lambda is fully up and running by checking its status on the AWS Service Health Dashboard.

Troubleshooting Alexa to Lambda interactions can be done via AWS Lambda. The Lambda function panel will have tabs for Code, Configuration, Triggers, and Monitoring. "Monitoring" is where you can view logs to see the requests that come in from the Alexa Skills Kit. Most of the time, you'll be able to find the error here. A lot of times, you'll see errors because you didn't change some of the default values in the main.py code in lines 14, 15, and 24.

If you're still stuck, read the excellent step-by-step guide from @tigerbrain.

Alexa Skills Kit Documentation

The documentation for the Alexa Skills Kit is available on the Amazon Apps and Services Developer Portal.

Resources

Here are a few direct links to Alexa and Lambda documentation:

Callouts

Special thanks to the contributors who help keep this alive. Check out https://github.com/arraylabs/myq for some great work that keeps inspiring this project, and @tigerbrain's Multi Door Support work.

Disclaimer

The code here is based off of an unsupported API from Chamberlain and is subject to change without notice. The authors claim no responsibility for damages to your garage door or property by use of the code within.

alexa-myqgarage's People

Contributors

jbnunn avatar jcostom avatar jebware avatar robrighter avatar sconaway avatar tigerbrain avatar wblakecaldwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alexa-myqgarage's Issues

Multiple garage doors

Is there any way that this can support multiple doors? I'd be happy with it opening/closing both at the same time, but, ideally I can say "Close left garage door, open right garage door"

Can't get this to work.

I think I have followed the instructions to the letter but can't get it to work. Every time I try to give Alexa a command I get "There is a problem with the requested skills response"

I don't know where to look. Any assistance would be appreciated.

No 'Blank Function' in LAMBDA blue prints.

I'm attempting to create the LAMBDA function and the blueprint 'Blank Function' isn't an option. I have tried a few others, unfortunately I don't see any option to upload the code.

Instructions current?

Hi, I apologize up front as I'm not a dev, but I'm trying to follow your instructions on setting up an Alexa Skill. None of the items you posted in the instructions were available, I have a feeling Amazon has changed the UI/steps since you posted the instructions? I'm hoping that's the case since I can't seem to get even close to your instructions. If you have a minute would you mind checking and seeing if they have changed things?

Errors

This is the Log:

START RequestId: 91599ffe-5c39-11e6-bbdd-5d14577d3be3 Version: $LATEST
'UserId': KeyError
Traceback (most recent call last):
File "/var/task/main.py", line 31, in lambda_handler
login()
File "/var/task/main.py", line 94, in login
myq_userid = response["UserId"]
KeyError: 'UserId'

END RequestId: 91599ffe-5c39-11e6-bbdd-5d14577d3be3
REPORT RequestId: 91599ffe-5c39-11e6-bbdd-5d14577d3be3 Duration: 440.80 ms Billed Duration: 500 ms Memory Size: 128 MB Max Memory Used: 20 MB

This is the Lambada request i'm using:

{
"session": {
"sessionId": "SessionId.dd449f7b-c202-4006-b1a1-0441b6f54942",
"application": {
"applicationId": "amzn1.ask.skill.f82eae7f-3c7f-476f-8ce7-41c7a15fc8f3"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.AFP3ZWPOS2BGJR7OWJZ3DHPKMOMJUHMBDZCXQSI4KAQ4MFH25X764YRBSUVLD6Y3RCK5XBUMJJRBJNWHNLG5YORXC35QM7RFVVY5TPPNSRAIE7NURINFZ74MHYLRJEFV3RASWXCHKX7PMZ6OD3GQGDZHO72AV3PJQGWN7VB2XIAHST5DFYRXKJK2J2JIBZ5BY622S7FLG22MXXA"
},
"new": true
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.d0ff9410-f895-455a-8ab2-903de173bad3",
"locale": "en-US",
"timestamp": "2016-08-06T18:35:57Z",
"intent": {
"name": "StateIntent",
"slots": {
"doorstate": {
"name": "doorstate",
"value": "down"
}
}
}
},
"version": "1.0"
}

Code is attached

Code.zip

Integration stopped working

Hi, I was able to get everything work great. It worked for months. Recently, perhaps the last 1 to 2 months, it has stopped working. Has something changed?

Last steps?

So, I went ahead and created this Skill and it works great through testing. Am I supposed to leave this in development state, just so I can use it? It looks like I need to get it certified and published, however, I have my ID's in the code, so that wouldn't work.

Just wondering where I go after testing. Thanks!

App ID issue

I followed all the steps in readme file, tried it twice.
When I test the app in the service simulator with "ask garage door to open", I get an answer from Lambda. But the answer is the default help ("You can open or close your garage door by saying, ask my garage door to open."). The door doesn't open.

When I test the Lambda function, I see the following an error in the log: "session': KeyError
Traceback (most recent call last):
File "/var/task/main.py", line 25, in lambda_handler
if event['session']['application']['applicationId'] != "amzn1.ask.skill.852e5631-63de-42d0-9e1b-8e550f2e25a8":
KeyError: 'session'

(I changed the app ID digit just for privacy. The app ID is copy and pasted from the app ID.

What am I doing wrong?
Jordan.

"GarageDoorOpener" device type not supported

When I list devices on the MyQ API, I don't have one where dev["MyQDeviceTypeName"] == "VGDO" but I do have one of type "GarageDoorOpener", and I was able to get this script to work with that device. I'm assuming this is due to some difference in my hardware setup.

I'm going to submit a PR so the script will support a device with either type. Thanks!

Don't require users to embed passwords in source

AWS Lambda provides a feature called "encryption helpers" that makes it super simple to store secrets encrypted in environment variables, rather than modifying the source to include the unencrypted secrets.

To use this:

  1. Navigate to the IAM console in AWS
  2. Create a new encryption key
  3. Grant use privileges for that key to the role that you're using for the lambda function
  4. In the Lambda console, go to the configuration for the lambda function
  5. At the bottom, enter the secret(s) (e.g. username and password) into environment variables, and use the encryption helper to encrypt them.
  6. Use the "code" button next to each environment variable to get a code snippet of how to use it.

I've modified main.py to use encryption helpers and attached it (also changed from print to logging for debug output).

main.py.txt

Update Directions

An additional step needs to be added for setting up the AWS Lambda function. At least as of Oct 2016 you must select US East (N Virginia) for your AWS region to get the Skills Kit trigger option.

Publicly publishable skill

In the absence of MyQ having really any desire to release any integrations themselves, I am curious on if there is any desire to make this project "release capable", having worked through it, it would seem the only requirement to making this "user agnostic" is to provide an Alexa app interface for providing credentials...

I am willing to help contribute to this end goal, as it feels like there is much angst by the less technical owners of the MyQ openers.

Error Message

received following error

START RequestId: 3dc6c294-fc78-11e6-a745-efa006dffcd1 Version: $LATEST
Syntax error in module 'main': expected an indented block (main.py, line 154)

END RequestId: 3dc6c294-fc78-11e6-a745-efa006dffcd1
REPORT RequestId: 3dc6c294-fc78-11e6-a745-efa006dffcd1

Door State is incorrect

Updated main.py got this skill working again for me but now when I ask alexa if my door is open and it isn't she says yes your garage door is open. When I ask if it is closed when it is she says no your garage door is open. Any ideas?

Handler Step

In order to get this to work I needed to name the "Handler" to "main.lambda_handler" to match main.py. Hope that helps someone!

Login URI changed?

I'm not sure, but I think maybe the login/host URI might've changed?

This has been working beautifully for the past month, but starting in the last day or two, I'm getting the following:

No JSON object could be decoded: ValueError Traceback (most recent call last): File "/var/task/main.py", line 32, in lambda_handler login() File "/var/task/main.py", line 89, in login response = requests.get(login_uri()).json() File "/var/task/requests/models.py", line 808, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib64/python2.7/json/init.py", line
No JSON object could be decoded: ValueError
Traceback (most recent call last):
File "/var/task/main.py", line 32, in lambda_handler
login()
File "/var/task/main.py", line 89, in login
response = requests.get(login_uri()).json()
File "/var/task/requests/models.py", line 808, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python2.7/json/init.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

If I'm reading that correctly, it appears I'm not able to log into the myq site? My login info hasn't changed. And, actually, both the site and my phone app still work. Just not Alexa. I've made no other changes to code, other than specified in the directions. Also, the directions only specified <MYQ_LOGIN_USERNAME> and <MYQ_LOGIN_PASSWORD> in main.py, not the additional fields including:

myq_userid
myq_security_token
myq_cached_login_response
myq_device_id

Thank you in advance for any guidance you can provide! I really appreciate the work that was done on this!

Chamberlain API change?

Hey Guys,

I just installed the Chamberlain skill and it works great opening and closing the door. One problem: the skill always reports the door as open regardless of its actual position. (ie. I ask if the garage door is open and it reports yes even though the door is closed. The MyQ app from Chamberlain correctly knows the position so apparently the skill is not picking this up. I created the skill with the latest updates and my garage door is brand new (WD1000WF). Since the open/close commands work correctly. I am thinking maybe Chamberlain changed the door state api?

Any ideas would be very appreciated.

BTW. Thanks all for this skill. It's awesome!

Dave
Friday Harbor, WA

Error in Testing

hi

Whenever I try to test the skill i get the error "The remote endpoint could not be called, or the response it returned was invalid.".

Any help would be greatly appreciated

Lambda now fails

I updated to your latest code but I still get the "There was a problem with the requested skills response" from Alexa.

Looking at Lambda logs I get the following

No JSON object could be decoded: ValueError
Traceback (most recent call last):
File "/var/task/main.py", line 32, in lambda_handler
login()
File "/var/task/main.py", line 95, in login
response = requests.get(login_uri()).json()
File "/var/task/requests/models.py", line 808, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python2.7/json/init.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Any suggestions whats gone wrong please?

line 24 help

i have been playing with this trying to get it working for the last couple weeks. any help would be greatly appreciated. thank you

START RequestId: 2cff6fcb-0644-11e7-b64f-01b9fcbda5a0 Version: $LATEST
'session': KeyError
Traceback (most recent call last):
File "/var/task/main.py", line 24, in lambda_handler
if event['session']['application']['applicationId'] != "amzn1.ask.skill.bbdef27c-0f33-42d1-9a1c-00e7da37ecf9":
KeyError: 'session'

END RequestId: 2cff6fcb-0644-11e7-b64f-01b9fcbda5a0
REPORT RequestId: 2cff6fcb-0644-11e7-b64f-01b9fcbda5a0 Duration: 0.60 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 16 MB

Does this still work?

Getting an error when calling alexa, The SpeechletResponse must not be null. Followed all instructions. Can't seem to get it working. Want to make sure everything is correct and still working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.