Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register
  • We just completed a significant update, but we still have some fixes and adjustments to make, so please bear with us for the time being. Cheers!

Model S REST API

rdrcrmatt

Member
Jun 27, 2013
607
31
Milwaukee
Depends on what you are using. All the logging I was doing was just Python and a few easily installable packages. If you're using something like VisibleTesla then you'd need Java, etc.

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. :(
 

superraz375

Member
Apr 16, 2013
88
5
Dallas
If any of you have v7.0 already, you should try to see if there are any new endpoints and commands/statuses available from the API. I am excited to hear if there is any new functionality added.
 

Pete90D

Fan of Red Lights
Jul 25, 2015
478
4
Bay Area, CA
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.
 

rdrcrmatt

Member
Jun 27, 2013
607
31
Milwaukee
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.
 

hans

P631
Sep 27, 2012
1,132
13
Menlo Park
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?
 

wk057

Senior Tinkerer
Feb 23, 2014
5,651
11,371
Hickory, NC, USA
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

 

tliving

Member
Mar 8, 2014
751
102
New England, USA
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?

 

tliving

Member
Mar 8, 2014
751
102
New England, USA
A second question, it seems inside temp can only be retrieved by turning on the climate control which is fine, I flip it on, collect the data, then flip it off. The only problem with that is when I get in the car its shut off. How are people working around that?
 

tliving

Member
Mar 8, 2014
751
102
New England, USA
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?
 

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top