Tesla API Access


The following provides an example of how to use webCoRE to access the Tesla API.

The first piston obtains the required OAuth API token and expiration date, plus the Vehicle ID. It also creates a new token prior to the expiration date of the old one. Instructions for the piston are included in the comments just below the Define Variable section. Basically, just add your Tesla email address & account password, create the required Global variables, save and click Test.

The second piston will run successfully via the TEST button ONLY AFTER the first piston has been run successfully and your credentials have been stored in the global variables you created. The piston provides examples of the methodology for accessing the API and parsing the responses.

Whatever trigger you use to activate the pistons you develop from this information, remember that waking the car uses the battery. The usage is small, but waking the car too often could impact your range.

Of course this is only example. More data and more commands are available for those interested in developing their own pistons. For more information on the Tesla API see: https://www.teslaapi.io/ or https://tesla-api.timdorr.com/

Let me know if you find this useful. Good luck!

Edited 12/14/18: Updated original text and piston to focus exclusively on how to access the API and the proper method of parsing the JSON response.

Tesla Powerwall Logging

@bthrock you are killing me with this piston :joy::grin::grin:

I had two dreams,
Create a smart home and buy a Tesla.
I had forgotten about the Tesla:)

“Honey, you know how we talked about kids are going to the best colleges…let’s talk again:” :joy::joy::joy:

IF time changes to after {highschool}
IF kids grades are > good
IF We have plenty of money
Send them to great colleges

“I don’t think that our piston will trigger:))))”


Does this use the same API that the Powerwall systems use?


Yes, you would just need to modify the URLs for the specific states, settings, and commands.


Good, I can stop messing with this GoControl contact switch for a mains disconnect sensor then…


I don’t have a powerwall, but I’d be happy to try to answer any questions if something’s not clear.


Thanks. I want to be able to detect when we are pulling from the powerwall exclusively for night time use and when we are pulling from the powerwall due to a power outage so I can put the house into different levels of some sort of high-efficiency mode. The solar hub is a zigbee device but I have no way of knowing how to gather what I need from it for a device handler.


Yeah, I’m not sure what data is available from the API but I would try logging info from the HTTP requests shown here https://www.teslaapi.io/powerwalls/state-and-settings and see if it has what you need.

To be clear, I know this API incorporates Powerwall data, but I don’t know if it’s somehow limited to Powerwalls used in conjunction with Tesla vehicles. If there’s a separate and unique Powerwall API available for Powerwall-only owners, I’m not familiar with it.


Perfect. Disappointing the only way to access responses is via parsing the text.


Parsing a response from at HTTP request is standard with almost any API. And in webCoRE it’s very easy to do.


I see that now in your second piston. Thanks. Got it all working but there is not much I can really do with it until Tesla fixes a communication issue between one of my controllers and the hub.


Building on bthrock’s good work, I have written a piston to query and log the Powerwall’s data