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

Drive.State.Power Codes (1,11,21,4,-9)?

This site may earn commission on affiliate links.
I've successfully written a PowerShell script to get my Tesla's data from the well-known API : Tesla API. Run it hourly. Works great. I drag it into PowerBI - fun-with-data.

However, now that I'm accumulating data, I'm seeing this column; [drive_state.power] and the values shown. My google-fu is failing me. I can't find the decoder-ring for these values (1, 11, 21, 4, -9).

Any ideas? Thanks.

Eric V ('21/Y/Perf/Blue/White/FSD)

1618404350421.png
 
Sounds sketchy to me:
"

What are the client_id and client_secret values?​

Authentication to the Tesla API is done through OAuth. These values were retrieved from somebody's OAuth session and are now being used for API access.

Is this API official?​

Absolutely not. These endpoints are a result of reverse engineering Tesla's mobile applications and vehicle software."
 
Thought that at first as well. (pre-sharing an app key is odd, for sure, but not unheard of for unofficial apis as you can't register one yourself. It's diff than sharing a user's auth_token - that's a big no-no.)

It's a pretty popular project on GitHub actually (timdorr/tesla-api). There's a Python package for it (TeslaPy) as well, even some commercial products. Here's a post from 2016 on how to use the API (or at least the version at that time): Tesla API, Controlling your Model S and Model X

Elon is fully aware of all the 3rd party dashboard products, mobile apps (that sell your data back to you with shiny charts), etc. If he wanted to shut the API to your car down, he would in a snap. I suspect he likes seeing the maker-community coming up data-driven products and services.

There are about ~180 columns of data in the output. So far, this is the only coded col I can't figure out.

I would assume that a value of 1 was (driving), but then others started showing up. hummm.
 
  • Like
Reactions: EchoDelta
Not sure what the thumbs down was about on you there but I think you are looking in the the wrong forum section. The average person here wont understand any of that (maybe thats why the thumbs down, someone that doesn't understand). There is another forum section I have seen somewhere here that you might get better info from or search for the scanmytesla app, they had a spreadsheet that called out a bunch of mapped values (pretty sure all those guys are working together though so you may already have it). IT looks to me like that is going to be related to watts but has a multiplier to make it accurate but that is my guess. I havent cared enough to put the effort in yet to give you a solid answer though.
 
You are right, - the average person won't comprehend what's going on... my main concern is that a naïve person wandering into using a hacked api to allow access to their car will get into trouble It is a lot more risky given the liklihood that there will be ongoing efforts to hack into tesla software for malicious purposes. A 'Tesla API' trojan horse would be a perfect way to hack a car... The average person is not going to really sift through what is on github to be sure it's legit...

I'm all for wringing data out of my car to figure out what the heck is going on. Personally I think tapping into vehicle data using ScanMyTesla OBDII is a safer option and doesn't compromise the security of the vehicle, and you get to take advantage of a lot of reverse engineering that folks have done looking at Tesla OBD data, though its always a step or two behind... but no Oauth or Internet involved!

But the idea of using a hacked api with web access that technically can drive my car [This API uses a standard WebSocket that exchanges JSON objects to convey state information and issue commands during the Autopark session.} freaks me out and sounds like a recipe for eventual disaster in someone's hands...

Have fun! Though I'm glad there are people as adventurous as you out there figuring things out, it still scares me.
 
I've successfully written a PowerShell script to get my Tesla's data from the well-known API : Tesla API. Run it hourly. Works great. I drag it into PowerBI - fun-with-data.

However, now that I'm accumulating data, I'm seeing this column; [drive_state.power] and the values shown. My google-fu is failing me. I can't find the decoder-ring for these values (1, 11, 21, 4, -9).

Any ideas? Thanks.

Eric V ('21/Y/Perf/Blue/White/FSD)

View attachment 653673
Welcome to the forum!