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

Nikola, an Amazon Echo/Skill for your Tesla

This site may earn commission on affiliate links.

wayner

Active Member
Oct 29, 2014
4,297
1,790
Toronto
Nikola is an Alexa skill created by Michael Kolowich and Andrew Payne to allow you to use an Amazon Echo to get information about your Tesla and to take certain actions on your Tesla, like start charging, unlock, lock, etc. This Skill leverages off of the Tesla Python JSON module written by Greg Glockner.

It allows you to ask your Tesla things like:
What is the charge level?
How far can I drive?
What is the temperature of my car?
Unlock my car
Lock my car
Start charging

This skill is written for deploying on a Cloud9 cloud server. I (wayner) have forked this code and made minor changes to be able to run the Skill on your own PC and then use a tunnelling application called ngrok to access the Skill. My fork is located here. Over time we will likely be merging my fork back into the main module.

Enjoy and please post any bugs/issues or suggestions on how to improve.
 
Nikola is an Alexa skill created by Michael Kolowich and Andrew Payne to allow you to use an Amazon Echo to get information about your Tesla and to take certain actions on your Tesla, like start charging, unlock, lock, etc. This Skill leverages off of the Tesla Python JSON module written by Greg Glockner.

It allows you to ask your Tesla things like:
What is the charge level?
How far can I drive?
What is the temperature of my car?
Unlock my car
Lock my car
Start charging

This skill is written for deploying on a Cloud9 cloud server. I (wayner) have forked this code and made minor changes to be able to run the Skill on your own PC and then use a tunnelling application called ngrok to access the Skill. My fork is located here. Over time we will likely be merging my fork back into the main module.

Enjoy and please post any bugs/issues or suggestions on how to improve.
Will this work on any Alexa?
 
Yes, but currently there is a bit of config work for you to do such as setting up a back end process to handle the requests. Hopefully we will be able to set up one service for everyone to use but the issue currently is figuring out how to securely authenticate individual users.
 
  • Disagree
Reactions: RubberToe
I have been running this on a Pi3. It should work on any Pi, but Pi3s would be recommended as they are much faster. But I would recommend that everyone try to implement on a Cloud9 server.

Not sure about the multiple cars, probably not right now but we could try to add the code to do so I am guessing that right now it will pick whatever is the first car in your account.
 
I have been running this on a Pi3. It should work on any Pi, but Pi3s would be recommended as they are much faster. But I would recommend that everyone try to implement on a Cloud9 server.

Not sure about the multiple cars, probably not right now but we could try to add the code to do so I am guessing that right now it will pick whatever is the first car in your account.

We have separate accounts believe it or not...my wife's car auto-locks but it would be handy to use this when I have to access her car instead of hunt for the keys!
 
If you have separate accounts then this shouldn't be an issue. Here is how I would set it up - call one of them Nikola in the Echo Skill setup page. Call the other one something else. Then the car that the Skill is using will simply depend on the Invocation name that you use. The downside is that this is essentially using two skills so it will require using two instances of the python code and two instances of ngrok or a cloud9 server, but that shouldn't be a big deal, you just have to make a minor change in the code to run one of them on port 5001.
 
  • Informative
Reactions: SW2Fiddler
Will it work with multiple cars?

@rog - what exact PI do you have?

I have a Pi3, Model B.

But I would recommend that everyone try to implement on a Cloud9 server.

I tried that, but don't like the fact that I have to set the project to "public" in order to get it to work (I am using the authentication token directly in the code in order to be nice to the Tesla API).
 
I tried that, but don't like the fact that I have to set the project to "public" in order to get it working (I am using the authentication token directly in the code in order to be nice to the Tesla API).

I created a fork in GitHub that allows it to accept a passed in token. Sadly, I can't get Alexa and Tesla to play nice to issue a token without an intermediary. If you can build a secure site to act as the intermediary, you can remove the token from within Cloud 9.

Alternatively, you can use my fork and use a different type of intermediary that would forward Alexa's request but with your token added into the JSON request. You won't get this as multi-user Alexa skill, but you will be able to get around the concern of the service being Public.
 
  • Helpful
Reactions: SW2Fiddler
I have now merged all of @wayner's changes into the main branch of my original code in my GitHub repository:

Nikola: An Alexa Skill (and Python intent handler) for Monitoring and Managing a Connected Tesla Automobile

@wayner and I are working together to keep our versions coordinated. If you want to run this on Cloud9, then you'll find instructions in my repository. @wayner's version (here) has instructions and code for how to run it on a local machine and tunnel through to the internet. Otherwise, the code bases are identical and we'll endeavor to keep them that way.

We're continuing to look for a collaborator who has the DevOps chops to help us turn this into a multi-user application!
 
  • Like
Reactions: rog
I wonder if this is contributing to increased vampire drain? I lost 6mi overnight... (no other changes)

The original version would prevent my car from sleeping. I forked it to prevent it connecting to the car until Alexa actually makes a call to it. My car since goes to sleep, but overnight it seems the Cloud 9 instance stops. I haven't figured out why that instance stops and if that is what is letting my car go to sleep overnight.
 
  • Informative
Reactions: sbtz
I have now merged all of @wayner's changes into the main branch of my original code in my GitHub repository:

Nikola: An Alexa Skill (and Python intent handler) for Monitoring and Managing a Connected Tesla Automobile

@wayner and I are working together to keep our versions coordinated. If you want to run this on Cloud9, then you'll find instructions in my repository. @wayner's version (here) has instructions and code for how to run it on a local machine and tunnel through to the internet. Otherwise, the code bases are identical and we'll endeavor to keep them that way.

We're continuing to look for a collaborator who has the DevOps chops to help us turn this into a multi-user application!

Cool, thanks a lot! Would be great if you could add an option to provide a Tesla Auth Token instead of username/password as an environment variable. I still don't feel comfortable storing my Tesla credentials somewhere in the "cloud" (I know, old fashioned :-D )
 
My car since goes to sleep, but overnight it seems the Cloud 9 instance stops. I haven't figured out why that instance stops and if that is what is letting my car go to sleep overnight.

That seems to be another disadvantage of the Cloud9 implementation (at least for the free version)... Inactive Workspaces · Cloud9

They kill inactive workspaces (I am assuming that also applies to Python processes running in them) after 2 hours.
 
  • Informative
Reactions: Cyclone
Cool, thanks a lot! Would be great if you could add an option to provide a Tesla Auth Token instead of username/password as an environment variable. I still don't feel comfortable storing my Tesla credentials somewhere in the "cloud" (I know, old fashioned :-D )

It's an easy change to do in your application.py file. Change line 36 from "tesla_connection = teslajson.Connection(TESLA_USER, TESLA_PASSWORD)" to "tesla_connection = teslajson.Connection(TESLA_USER, TESLA_PASSWORD,ASSIGNED_TOKEN)" and passing in your token in that third field. The first two fields can contain gibberish, they won't be used.
 
  • Helpful
  • Informative
Reactions: SW2Fiddler and rog