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

Tesla Owners API v3 enabled

This site may earn commission on affiliate links.
I'm working on a bash script that will let me see where my car is and do a few other useful tricks. One thing I would really love to do is send a URL to the web browser (which would have a short message encoded in the URL that would be displayed). I know I can send a navigation address and apparently video links, but I don't know if sending URLs to the browser is possible. If anyone has any ideas, let me know.

Meanwhile, I should put my script up on GitHub, as it's working pretty well so far (now that I switched to the new authentication).
 
Well, I've published my script:
pcrow/tesla_bash

I would like to launch URLs in the car's browser, not my desktop browser (I already do that). The idea is I can run my script at home, and send a message like "Please pick up dinner at Doragon Ramen. It should be ready at 5:30" which would cause the car to pop up the web browser and connect to a web page that would display that message in large print. Like sending a text message, only not using a phone.
 
As of yesterday, the API is no longer working for me. I don't think it's related to throttling authentication as I'm only hitting it once an hour to get the energy_left and total_pack_energy. Any suggestions, including how to get these values locally vs remote API, welcome.
 
It's still working fine for me. Occasionally they have outages at Tesla's end, but I haven't heard anything. It's also possible that they will block specific users if they notice accesses that seem abusive, though I haven't heard of them doing so. They have cut off specific vehicles that have been heavily modified (as in hacked to run custom software).
 
I have been typing in the following script in my Command prompt to get an access token; can someone help me translate it under the new API?

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "grant_type=password" -F "client_id=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384" -F "client_secret=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3" -F "email=[email protected]" -F "password=_____________" "https://owner-api.teslamotors.com/oauth/token"

Many thanks in advance.
 
Does anyone know a good path for me to begin to pursue a possible API connection for the Tesla Inverter? The Tesla Inverter does not require a gateway but instead has all the networking capabilities built in to it. I would like to find out if Tesla does or plans to enable API endpoints for the inverters to fetch my solar generation. I would like to use the data + Home Assistant to make a grid of system tied devices and add red/green LEDS to indicate to people in the house if the current solar generation alone is sufficient to power that device.
 
I’d love some power shell examples....
My C# logger previously had custom code for authentication. When it stopped working due to the Tesla-side changes, I started updating and got annoyed (and bored) so I switched to TeslaAuth.


In the past I've had good luck using .NET packages with Powershell.

Just sharing in case it's useful or saves you some time.
 
I had developed my own and it stopped working after a few weeks. Turned out Set-Cookie was now set-cookie. Making that pattern match case insensitive in the code solved the issue.
I'm getting a timeout on the first step. The GET at https://auth.tesla.com/oauth2/v3/authorize doesn't work. I'm setting the header with:

{"User-Agent": "Mozilla/5.0 (Linux; Android 10; Pixel 3 Build/QQ2A.200305.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.81 Mobile Safari/537.36", "x-tesla-user-agent": "TeslaApp/3.10.9-433/adff2e065/android/10", "X-Requested-With": "com.teslamotors.tesla"}
 
I'm getting a timeout on the first step. The GET at https://auth.tesla.com/oauth2/v3/authorize doesn't work. I'm setting the header with:

{"User-Agent": "Mozilla/5.0 (Linux; Android 10; Pixel 3 Build/QQ2A.200305.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.81 Mobile Safari/537.36", "x-tesla-user-agent": "TeslaApp/3.10.9-433/adff2e065/android/10", "X-Requested-With": "com.teslamotors.tesla"}

More critical in the first step when calling authorize are the GET params: client_id, code_challenge, code_challenge_ethod, redirect_uri, response_type, scope, state. The headers above look more like what I use in step 3 when exchanging the authorization code for the bearer token.
 
I tracked it down to the user agent string I was using in the header:

{"User-Agent": "Mozilla/5.0 (Linux; Android 10; Pixel 3 Build/QQ2A.200305.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.81 Mobile Safari/537.36"}

If I remove that, it works fine. Considering that many other scripts use that user agent, I'm wondering if there's some blocking going on by Tesla.
 
Last edited:
Anyone know how to set the storm watch via API? I see the storm watch endpoint in the cloud api, but not sure what parameters to send in order to enable/disable it.
Sorry for a late reply - I haven't been reading this board very regularly lately.

In case it's still useful, here is what I use to turn storm watch on and off:
endpoint: /energy_sites/<site_id>/storm_mode
payload: {"enabled": true}

(paraphrased from javascript, typos possible)

I'm using this with IFTTT to enable Storm Watch mode for off-peak only.
 
Does anyone know a good path for me to begin to pursue a possible API connection for the Tesla Inverter? The Tesla Inverter does not require a gateway but instead has all the networking capabilities built in to it. I would like to find out if Tesla does or plans to enable API endpoints for the inverters to fetch my solar generation. I would like to use the data + Home Assistant to make a grid of system tied devices and add red/green LEDS to indicate to people in the house if the current solar generation alone is sufficient to power that device.
If you're ok with looking at javascript code, the easiest way that I've found to get started is to unbundle the current Android APK to see what endpoints are supported. The code is a little painful to read because it's clearly machine-generated, but I've been able to decipher what parameters are being passed in most cases.
In addition, there probably is a way with a rooted Android device to sniff the network traffic, but it appears like the app does certificate pinning so it was beyond my ability to figure out with my iPhone.
Does the inverter have a local web interface? That would be the other way to get the data if it isn't available from the server.
 
If you're ok with looking at javascript code, the easiest way that I've found to get started is to unbundle the current Android APK to see what endpoints are supported. The code is a little painful to read because it's clearly machine-generated, but I've been able to decipher what parameters are being passed in most cases.
In addition, there probably is a way with a rooted Android device to sniff the network traffic, but it appears like the app does certificate pinning so it was beyond my ability to figure out with my iPhone.
Does the inverter have a local web interface? That would be the other way to get the data if it isn't available from the server.
The inverter does have a web interface, but it is only available when connecting to the Inverter's access point and only right after the inverter has power cycled. Connecting to Tesla Solar Inverter | Tesla Support This only displays configuration information. Other than that the device shows no information when connecting to it on my home's local network.

I don't mind looking at javascript (I do that for work anyways) but I am unsure how to unbundle the APK. Any tips you can give for unbundling an APK to view source would be greatly appreciated. I did try giving it a quick over on Google and didn't see much that seemed relevant.
 
Sorry for a late reply - I haven't been reading this board very regularly lately.

In case it's still useful, here is what I use to turn storm watch on and off:
endpoint: /energy_sites/<site_id>/storm_mode
payload: {"enabled": true}

(paraphrased from javascript, typos possible)

I'm using this with IFTTT to enable Storm Watch mode for off-peak only.I
Is there anywhere where I can find documentation for these APIs - e.g. is there an api to force charging of the power wall from the grid - I assume the storm_mode only enables the storm mode - not starts the charging