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

Model S REST API

This site may earn commission on affiliate links.
When my linux box was a VM (x86) I just ran some simple bash scripts to keep the data logging going.

I don't know python much at all unfortunately. :(

Ah, that's probably why. The bash scripts are going to depend on other apps. You should be able to apt-get them if you're using Debian based system or other PM depending on the distro.

I'll eventually be open sourcing all my code. I have some bigger plans to make it more useful (hopefully) so when I get some time to work on personal projects I'll finish it up.
 
Ah, that's probably why. The bash scripts are going to depend on other apps. You should be able to apt-get them if you're using Debian based system or other PM depending on the distro.

I'll eventually be open sourcing all my code. I have some bigger plans to make it more useful (hopefully) so when I get some time to work on personal projects I'll finish it up.

thanks, ill check into things again.

I would love to have something I could run as an app that would use Php or something to dynamically update webpages with in my webserver. I had a page written that queried the latest line of the output from the streaming that then showed my cars location on a goodie map. Was handy for telling people where I was while enroute without having need to get the tesla app and my pw.
 
with 7.0, is_front_defroster_on has a value of 3 whenever the climate control is on. (and a value of 1 if front defrost is actually on). Any ideas what the 3 is supposed to mean?

Seems backward but its likely a bitmap with one bit representing the on/off state of the climate control and the other bit representing the on/off state of the front defroster.

11 = 3 which means defroster is off (default state) and climate is on (default state)
01 = 1 which means defroster is on (not default state) and climate is on (default state)

Does it show 2 if both defroster and climate control are turned off?
 
Hmm... how long have these been in there? Is there a way to actually toggle these via the API now?

seat_heater_left=0
seat_heater_right=0
seat_heater_rear_left=0
seat_heater_rear_right=0
seat_heater_rear_center=0
seat_heater_rear_right_back=0
seat_heater_rear_left_back=0

 
Hi folks, I don't have an API usage problem as its working reliably for me with my S85 (pre-AP) with 7.0. Many thanks to the people that documented the API and provided various examples.

The question I do have is on the data itself. I'm building a logger to record my daily miles driven and i'd like to include in that the energy used and then the calculated Wh/mi from those two numbers.

Getting the mileage, and current battery state/level is easy, but how do I convert things to kWh?

# ./tesla.py --state
{'inside_temp': 62.06, 'soc': 82, 'outside_temp': 57.2, 'odometer': 48582, 'range': 206.51, 'version': u'2.7.56'}

Basically I want to record the "Since Last Charge" information at the end of every day using the data provided in the API or calculations based on that. Any ideas?

 
Unfortunately I don't believe that energy usage is currently reported via the API.

Right, the kWh are not in the data but i'm wondering if some basic math can be used. For instance when they have a range in rated miles, if they use 300Wh/mi for a rated mile then you could potentially just multiply things to get to kWh:

(rated miles left) * 300 Wh/miles = xxx Wh

We've got values like these (my current status tonight):

battery_range: 200.08
ideal_battery_range: 231.47

I think those are rated vs ideal.

If I take battery_range and multiply by 300 I get 60.024kWh.

But, my current state of charge is:
battery_level: 79

I have a S85, so 60.024/85 is roughly 71%.

The 71% doesn't match the 79%. So thats confusing.

The odd part is that 79% of a 90% charge limit is 71%. Not sure if thats just luck or what. The dashboard reads 79%.

So is that range indicator on the dashboard an indication of % of total battery of % of the set charge level?

Any thoughts on all this?