How you can optimize your Tesla experience by analyzing your historic driving & charging data
By: Paul Strobel
Tags: Tesla, API, Energy Efficiency, Battery, Data

How you can optimize your Tesla experience by analyzing your historic driving & charging data Paul Strobel Jan 12, 2020·5 min read

https://youtu.be/LUWQ_7s3eDE. A shorter video can be found at the end of this article.

With this article I want to show you how you can understand the data of your Tesla, how you can access it yourself and what you can make out of it to improve your Tesla experience.

Here are some questions you might want to answer with data:

How does the battery degrade over time?

How much power did your Tesla loose overnight while it was parking in the garage not charging?

How much energy do you gain through regenerative braking?

What was the energy consumption of your last rides?

The official Tesla app can give you insights into your momentary state of your car. However, at this point of time it offers only limited information regarding your driving and charging history. You can answer these questions by either using a data tracking service or by fetching the data yourself. The video at the bottom gives an overview of both approaches and answers these questions.

Analyzing the energy flows of a Tesla Model S 75D with a data tracker, Januray 1st, 2020.

I reached out to Teslametric, one of the data tracking services out there, to learn more about this matter. They provided detailed insights of how they do it which I find very helpful. I will share them here — however, there is no sponsorship. There are also other trackers but I don’t have any experience with them. If you do, please comment below.

The following dashboard shows energy flows of a Tesla Model S 75D — with a view of historic data from 2019 in Teslametric. For more explanations on it, check out the video at the bottom of this article.

Energy flows of a Tesla Model S 75D viewing historic data from 2019 in Teslametric.

How to get the raw data yourself

If you want to play around with raw data yourself instead of using a service, the rest of this article will help you to get started. There are four questions I want to address:

What information can you access? How can you get access to the data? What security aspects should you be aware of? Will frequently accessing your car’s data affect battery drain?

Every Tesla is connected to the internet and continuously sends data to Tesla’s own servers — as long as network coverage is available or the car is connected through WiFi. The standard connectivity package, which is included with every Tesla, is sufficient to record and access your data through the Tesla API. In fact, the official Tesla app uses the same API as well to display information to you.

1. What information can you access?

You can receive realtime information about your car’s current state. There are a lot of attributes you can access, here are only a few that might be relevant to understand your energy consumption better:

GPS location

Speed

Battery level

Estimated Range

Odometer

Current state of charge

Outside temperature

Battery heater

..

Have a look at the full attribute list here.

2. How can you get access to the data?

A lot of the data that a Tesla produces can be accessed through an API. There is no official API documentation but there is unofficial API documentation:

You can access the API with token-based authentication. When you generate a token, you will receive an access token and a refresh token. The access token can be used to authorise access to the data. It expires automatically after 45 days. The refresh token can be used to request a new access token after the old one expired. After you generated a token, you won’t need your Tesla username and password from this point on to access data. If you need help getting started with the API and you get stuck with the documentation, here is a technical tutorial from Jimmy Huang which might help. After you have created a token, you can start to poll data from a Tesla remotely.

3. What security aspects should you be aware of?

The most important thing you have to know is that whoever has access to your car through the API can not only read information but also perform actions on your car. This is not trivial because your car can be unlocked through the API. So what can you do?

Activate “PIN to Drive”

The first thing you can do is to activate the feature “PIN to Drive” in your Tesla. This way nobody can drive away with your Tesla. To activate it go to your Tesla’s touchscreen and select -> Controls -> Safety and Security -> “PIN to Drive” and follow the setup instructions.

Evaluate the service you plan to use

You can add an additional security layer by only using services that while offering reading functionalities (GET requests) do not offer to perform actions on your car (POST requests). If a service offers to perform actions, it should at the very least offer Two-Factor Authentication in my opinion.

Revoke access

If you gave a token to someone to do some data analysis for you and you want to revoke the access, simply change your Tesla.com password, this will invalidate all tokens immediately.

Dear Tesla Motors, if you read this, please consider to add tokens which only grant read access. This way, users, who only want to access their data but don’t want any actions to be performed, have an easier way to eliminate security concerns.

4. Will accessing your car’s data frequently affect battery drain?

Be aware of energy efficiency when making API calls during parking. If you keep polling data while it parks (and is not charging) that can prevent it from falling into a so called deep sleep mode. In this mode the car shuts down the internal busses which limits the battery drain significantly (it does not stop it completely though). To let the car fall asleep you have to “leave it alone“ for some time, i.e. stop polling. However, if the car starts a new trip during this time span, you will loose the data for the beginning of that trip — some 45 seconds. So trying to put the car asleep every time it stops is not an option as well. You have to keep a reasonable balance between data loss and energy loss. Teslametric solves this issue by predicting the probability of your next trip shortly after your previous trip. This prediction is made on the basis of your trip history and your weekly usage patterns.

I hope this guide has been helpful. I summarized it in a shorter video here:

What would you do with the data? And what experiences do you have with this matter and other trackers? Comment below and let me know!

Paul