💡This guide requires a minimal understanding of programming, including familiarity with terminals and command lines.
💡This tutorial uses Docker to install TeslaMate. If you're working in a soft router environment, additional steps like port forwarding may be needed for browser access. Since my Mac computer stays on indefinitely, I installed it on Docker for Mac.
💡One minor drawback is that TeslaMate cannot retrieve historical vehicle data. As a result, you can only view driving data recorded after installing TeslaMate, and the TeslaMate service must remain running to continue logging driving information.
Introduction
“TeslaMate,” loosely translated as “Tesla Companion,” is an open-source software that retrieves data reported by your vehicle to Tesla’s servers and displays it using Grafana, a web-based data visualization dashboard tool.
Tesla engineers collect this data for large-scale vehicle analytics, software optimization, battery charging improvements, and more. As individual owners, accessing this information allows us to better understand our vehicles’ detailed metrics, such as trip history, daily mileage, energy consumption, and charging efficiency.
The reason for this blog post is that TeslaMate’s documentation only covers installation (which is straightforward) but doesn’t explain how to configure the dashboard after installation to display the desired data. Meanwhile, many SEO-driven content farms simply copy-paste official documentation, making it difficult to find useful information. Currently, I haven’t found any comprehensive guide covering installation to final setup—so this article will walk through the entire process.
Here’s a preview of the final result (users can customize the dashboard):
1. Installing Docker
As mentioned earlier, I’m using Docker for installation. TeslaMate’s documentation requires Docker and Docker Compose (don’t worry about what they are—just install them). By installing Docker Desktop, both are included. Download Docker Desktop here:
After installation, launch Docker Desktop. Then, choose a directory (all TeslaMate files will reside here—do not delete it) and place the official docker-compose.yml file inside. In my case, I placed it under ~/Developer/Docker/TeslaMate. The docker-compose.yml content is as follows:
## 2. Logging in and Authorizing Your Tesla Account
Afterensuringnoerrorsinthepreviousstepandconfirmingallservicesareinthe"Running"state(youcanchecklogsbyclickingeachservicenameinthescreenshotaboveforanyerrors),open`localhost:4000`inyourbrowser.You’llbe prompted to enter an API Token and Refresh Token. The official documentation explains how to obtain these here:
Here,I’lluse the third method:"Tesla Auth (macOS, Linux, Windows)."Clickthelinkbelowtofindtheversionforyoursystemanddownloadthecorrespondingfile(anexecutable):
{%render_bookmarkurl="https://github.com/adriankumpf/tesla_auth#download"title="GitHub-adriankumpf/tesla_auth:SecurelygenerateAPItokensforthird-partyaccesstoyourTesla."img="https://opengraph.githubassets.com/14ed85d2b3ddb9d5945d743bce95d70195e338a20492ab583d95d8c0d4f14ebd/adriankumpf/tesla_auth"yid=""bid=""%} Securely generate API tokens for third-party access to your Tesla. - GitHub - adriankumpf/tesla_auth:SecurelygenerateAPItokensforthird-partyaccesstoyourTesla. {%endrender_bookmark%}
Ifyoudirectlydouble-clicktoopen(oropenviaterminal),macOSmaywarnyouthattheexecutablefilecouldbedangerous.Goto`系统设置-隐私与安全性`andclick"Open Anyway".Afteropening,awindowwillpopuppromptingyoutologintoyourTeslaaccount.Onceloggedin,thepagewilldisplayyourTeslaAPITokenandRefreshToken(Iwon'tincludescreenshotshere).Copythesetothecorrespondingfieldsonthe`localhost:4000`page to successfully log in. The interface after successful login looks like this:
ADashboardisaninterfacethatdisplaysvariousdata,showing different Panels. A Panel is a module that queries the database for data and visualizes it. Each red box in the image below represents a Panel:
Afterclicking"Copy,"youcanpasteitintoanotherDashboard.Clickthe"Add Panel"buttonintheupperrightcorneroftheDashboard(orwhencreatinganewDashboardforthefirsttime).Ifyoudidn’tclick"Copy"inthepreviousstep,thefourthoption,"Paste from Clipboard,"won’tappear. The new Panel creation interface will look like this:
EachDashboardcansetVariablesforPanelstouse.HowdoPanelsuseVariables?PaneldataisretrievedviaSQLqueries,andpartoftheSQLsyntaxusesGrafana'sSQL template syntax. Below is the SQL query for altitude data:
```sql SELECT $__time(date), ROUND(convert_m(elevation,'$alternative_length_unit'))ASelevation_[[alternative_length_unit]] FROM positions WHERE car_id=$car_idAND $__timeFilter(date) ORDERBY dateASC
The terms enclosed in $ symbols are predefined Variables. Some are built-in, like $__timeFilter, while others are custom, like $alternative_length_unit. Custom Variables are configured in the Dashboard. Dashboard Variables are configured in the Dashboard Settings, accessible via the upper-right corner:
JSON Model
Sometimes, after copying a Panel from one Dashboard and pasting it into a new Dashboard, the Panel may not display data correctly. This happens because the Variables used by the source Panel weren’t copied from the source Dashboard to the new one, causing SQL syntax errors and preventing data retrieval. If a Dashboard has many Variables, copying them one by one can be tedious. How to solve this? The JSON Model can help.
The JSON Model is essentially the Dashboard configuration in JSON format. You can copy the corresponding fields from one Dashboard’s JSON Model to another. Variables correspond to the templating field in the JSON Model. Copy the relevant items from the list field in the source Dashboard’s JSON Model to the list field under the templating field in the target Dashboard’s JSON Model. (Remember to click “Save Changes” and then “Save dashboard”):
Grafana has many other advanced features, but for Tesla data visualization, understanding these basics is sufficient.
4. Configuring Grafana
After accessing localhost:3000, you’ll need to log in. The default username and password for the first login are both admin. After the first successful login, you’ll be prompted to set a new password. Once set, the interface will look like this:
Here, TeslaMate has already configured various dashboards for us. Click on this area on the left to open the folder and view the dashboards listed in the directory:
Feel free to open any one, such as Drive Stats, to see the various panels in the corresponding dashboard:
However, we likely want to aggregate panels from multiple preset dashboards into a new dashboard tailored to our needs. This requires using the operations mentioned in the previous step “Grafana Concepts”—copying panels, copying variables (copying JSON models). You can configure a dashboard that suits your requirements.
5. Other Notes
Here are some additional usage tips for Grafana, briefly outlined.
Configuring Panel Titles:
Click “Edit” at the top of the panel, then modify the title on the right side:
Map Not Displaying: No further explanation—requires a VPN environment.
Setting Your Dashboard as Default:
As shown here:
How to Synchronize Data Display Across Panels When Hovering Over One Panel in a Dashboard?
A common use case is hovering over a line chart panel to view driving speed while simultaneously seeing the corresponding location on a map panel. This can be resolved by adjusting the dashboard settings. Set it to the second option (default is the first):
Security? TeslaMate is open-source software from abroad, and its security is reliable.
How to Migrate Data When Switching Machines? Refer to TeslaMate’s documentation for detailed instructions.
How to Access Grafana Over the Public Internet? This requires DDNS—figure it out on your own.
Ultimate Reminder: Remember to click “Save” in the top-right corner after modifying a panel.
How to Set Up Timed Dashboard Refreshes: The refresh interval can be set in the top-right corner of the dashboard. This is typically used for displaying real-time data changes on a large screen throughout the day.
I often wish that when facing some key decisions in life, someone could tell me the best course of action so that I would not waste my precious time. Putting myself in others' shoes, I therefore write blogs often, hoping to record in this tiny corner of the vast Internet the once-in-a-lifetime experiences that matter to me, and to help those who seek help.