Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Model S Amazon Echo Integration

This site may earn commission on affiliate links.
By the way, another option is to just plug in a valid OAUTH code into the teslajson.py file if you already have on. But this will have to be manually changed every three months or so.

That did the trick for me to get the application up and running - still getting the "There was an error calling the remote endpoint, which returned HTTP 302 : Found" error on the Amazon side though.
 
That did the trick for me to get the application up and running - still getting the "There was an error calling the remote endpoint, which returned HTTP 302 : Found" error on the Amazon side though.

Fixed this by setting the cloud9 app to public. Doh!

(Hopefully that doesn't expose any of my credentials)
 
still getting the "There was an error calling the remote endpoint, which returned HTTP 302 : Found" error on the Amazon side though.
Sorry -- in my haste to write this up for you guys, I may have missed a critical step. In the Amazon developer panel, for your Alexa skill, you need to set the SSL certificate. For the Cloud9 instance, check the button that says:

" My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority "

Let me know if that works. I'm updating the instructions to reflect this addition.
 
  • Like
Reactions: sbtz
Sorry -- in my haste to write this up for you guys, I may have missed a critical step. In the Amazon developer panel, for your Alexa skill, you need to set the SSL certificate. For the Cloud9 instance, check the button that says:

" My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority "

Let me know if that works. I'm updating the instructions to reflect this addition.

Changed that setting, but it still required me to set the application share to 'public' on cloud9 for it to work. (not setting to public still returns the 302 error)

Also, don't want to turn this into a support thread, but some utterances don't work, for example any of the GetPluggedIn return "There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error" -- most do work very well though, and thank you again for posting this along with the writeup..
 
Last edited:
Changed that setting, but it still required me to set the application share to 'public' on cloud9 for it to work. (not setting to public still returns the 302 error)
Actually, you're right. Come to think of it I checked the "PUBLIC" button next to the Application URL in the Share screen. I will add that to the writeup and post.

I do need to do some regression testing on the utterances. This is work in progress, obviously. Unfortunately, my Model X has been held hostage by the Dedham Service Center for 2 weeks now, and I don't have a car to test on. With luck, I'll have it back tomorrow.
 
  • Like
Reactions: UnbeknownstToAll
I'm getting my Tesla on Saturday (complete surprise for the other half) and I got an Echo for xmas. Literally had a brain wave if this sort of thing existed. Disappointed that Mosaic not yet in the UK, but reading on I get hope! Hope in the from of you geniuses with far too much time on your hands. I'm a willing test participant and tech savvy but I don't have the time to spend so just posting in this thread to keep informed of updates as they come - looking forward to acting as a regular Jo beta tester!
 
I updated the application.py file and I'm still getting a 401, but I think my issue is different. I just got a new 90D last night (traded in my 85D), and right now, both cars show in my account.

I found that on the Tesla iOS app I had to switch vehicles (else I got a similar unauthorized message), as I no longer have access to the 85D. I may just have to wait until it drops off my account.
 
Last edited:
I still get the 401 error,
You may have been working with instructions before I amended them a couple of hours ago. You need to make sure to check PUBLIC box in the Cloud9 SHARE window in order to expose the server URL to Alexa. I had omitted that from the original instructions, but have amended them. The most current deployment instructions are now posted in the same GitHub repository.
 
I found and changed line 37 from
Code:
vehicle = tesla_connection.vehicles[0]
to
Code:
vehicle = tesla_connection.vehicles[1]
and I still get the 401 error, so maybe I have been locked out?

I got the 401 error until I just switched to using my oauth key instead. (still haven't been able to get it to work with the username and password)
 
You may have been working with instructions before I amended them a couple of hours ago. You need to make sure to check PUBLIC box in the Cloud9 SHARE window in order to expose the server URL to Alexa. I had omitted that from the original instructions, but have amended them. The most current deployment instructions are now posted in the same GitHub repository.
I must have gotten the most recent instructions, as I do have PUBLIC checked. Hmm...
 
Changed that setting, but it still required me to set the application share to 'public' on cloud9 for it to work. (not setting to public still returns the 302 error)

Also, don't want to turn this into a support thread, but some utterances don't work, for example any of the GetPluggedIn return "There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error" -- most do work very well though, and thank you again for posting this along with the writeup..
I think this can be fixed by changing 'charge_state' to 'charging_state' in line 289 of application.py. I have submitted the change request on this.
 
What do I need to do to switch it to oauth mode?
You need to get an OAUTH key and paste it into line 30 of teslajson.py. Here is a tesla file to get a key - make sure to replace [email protected] with your actual email and "your password" with your actual tesla password
Code:
#!/usr/bin/python
import requests
import json

#This file is used to retrieve a new token
oauthit = {"grant_type" : "password",
"client_id" : "e4a9949fcfa04068f59abb5a658f2bac0a3428e4652315490b659d5ab3f35a9e",
"client_secret" : "c75f14bbadc8bee3a7594412c31416f8300256d7668ea7e6e7f06727bfb9d220",
"email" : "[email protected]",
"password" : "your password" }
print oauthit

r = requests.post("https://owner-api.teslamotors.com/oauth/token",params=oauthit)
jsondata=r.json()
token=jsondata['access_token']
print (token)
 
I think this can be fixed by changing 'charge_state' to 'charging_state' in line 289 of application.py. I have submitted the change request on this.

That resolved the error, but 2 things: I noticed that there are several references to 'charge_state' in application.py - I wonder if they all need to be changed? Also, although this resolved the error, it returns the temperature of the car -- only in the Amazon Service Simulator though. It works as it should with an actual Alexa. Weird.

Also, I went through each of the utterances (well, one of each type) and the following aren't working for me (500 error):

GetPluggedIn (fixed)
GetTemperatures
GetStatus
GetStatusQuick
ChargeStartTime
ChargeSet
DataDump

I'll start taking a closer look at each to see if it's a similar issue as the charge_state charging_state switch. Thanks again to @BizJet for putting this together!
 
You need to get an OAUTH key and paste it into line 30 of teslajson.py. Here is a tesla file to get a key - make sure to replace [email protected] with your actual email and "your password" with your actual tesla password
Thanks for the code. I don't have any experience with Python, so forgive me if this is a newbie issue, but when I try running that in Cloud9, I get this:

Code:
  File "/home/ubuntu/workspace/get-token.py", line 13
    r = requests.post("https://owner-api.teslamotors.com/oauth/token",params=oauthit=r.json()
                                                                                    ^
SyntaxError: invalid syntax