Tech & GadgetsProjects & Hobbies

TeslaMate on a Synology: your Tesla's data, on your own server

Log every drive, charge and kilowatt-hour of your Tesla on your own Synology with TeslaMate: what it shows, how it works, and a safe install guide.

By Georgios Tsimplidis8 min read

My Tesla knows a lot about me. Where I drove this morning, how fast, where I charged, how much the battery lost overnight, where I park and for how long. The question is: who else gets to know?

There are apps that log all of this for you, beautifully. Tessie, the best known, costs USD 69.99 a year, and your car’s whole history lives on their servers. Or you can run TeslaMate on your own server, for free, and the history stays at home.

You can guess which one I chose. In Dare, then calculate I showed the numbers behind my home server; TeslaMate is one of the apps that make it pay. This guide shows how I run it on my Synology, step by step.

It’s part three of a small series:

  1. Portainer on a Synology: the control room for your containers.
  2. HTTPS for your home apps: the Synology reverse proxy: nice names and a trusted certificate.
  3. TeslaMate: this article.

What TeslaMate is

TeslaMate is an open-source data logger for Tesla cars. It talks to the same servers the Tesla app talks to, records what the car reports, stores it in your own database, and shows it in Grafana, a dashboard tool engineers use to monitor power plants and data centres. Here, it monitors one car.

It’s free, MIT-licensed, and maintained by a large community on GitHub. You need nothing from Tesla beyond your normal account.

What you get out of it

Once it runs, it quietly builds a history of your car. Some of the dashboards:

  • Drives: every trip on a map, with distance, duration, consumption and the temperature outside.
  • Charging: every charging session, how many kWh went in, at what power, and what it cost, once you tell TeslaMate your electricity price per location.
  • Efficiency: real consumption per 100 km over time, and how it changes with temperature. Winter in Switzerland, in one chart.
  • Battery health: the range the battery would give at 100%, over months and years. The best evidence of battery wear you’ll ever have, and very handy when you sell the car.
  • Vampire drain: how much the car loses while parked, and why.
  • States and timeline: when the car was asleep, online, driving or charging.
  • Updates: every software version the car installed, with dates.
  • Statistics: monthly kilometres, costs and efficiency.
TeslaMate overview dashboard: battery level 61%, range 249 km, odometer 45,773 km, temperatures, and a timeline of the car's states over 24 hours
The overview: battery, range, temperatures, and what the car did in the last 24 hours. (Yes, the car is called Darth Vader.)

My numbers, measured

Here’s what TeslaMate has logged on my Model 3 so far, over 14,894 km. No brochure values, no estimates.

Charging: 6.21 francs per 100 km

TeslaMate charging statistics: 127 charges, 2.69 MWh added, total cost CHF 929.33, CHF 6.21 per 100 km, CHF 0.32 per kWh on average, CHF 0.49 at fast chargers and CHF 0.25 on AC, with charging heatmaps, AC/DC split and the DC charging curve. The map of charging locations is blurred.
Charging statistics. The map of charging places is blurred: where I charge is nobody's business.
  • 127 charging sessions, 2.69 MWh put into the battery.
  • Total cost: CHF 929.33, of which CHF 238.04 at Superchargers.
  • CHF 0.32 per kWh on average, from three very different prices:
    • At work: AC charging at CHF 0.19 per kWh, the cheapest kilowatt-hours I get.
    • At home: CHF 0.28 per kWh, from the wallbox my landlord installed.
    • On the road: Superchargers and other fast chargers at about CHF 0.45 to 0.50 (TeslaMate measured CHF 0.49 on average).
    • Work and home together average CHF 0.25 on AC.
  • About 69% of the energy came from slow AC charging and 31% from fast DC, but in time, AC was 97% of the hours. Most of it happens while I sleep, at home, or while I work: slow and cheap does most of the work.
  • Result: CHF 6.21 per 100 km. That’s the real energy cost of my driving, Superchargers and road trips included.

Efficiency: winter costs you

TeslaMate efficiency dashboard: average consumption 153 Wh/km net and 182 Wh/km gross over 14,894 km, and a table of consumption by outside temperature, from 131 Wh/km at 20 °C to 208 Wh/km at -5 °C
Efficiency by outside temperature. The sweet spot is 15 to 20 °C.
  • Average consumption: 153 Wh/km while driving, 182 Wh/km including what’s lost while parked and while charging.
  • At 20 °C: 131 Wh/km. At -5 °C: 208 Wh/km. That’s almost 60% more energy for the same kilometre in a Swiss winter, as heating and cold batteries take their share.

Battery health: 96.4% after 45,773 km

TeslaMate battery health dashboard: usable capacity 58.7 kWh new and 56.6 kWh now, max range 424.5 km new and 407.4 km now, estimated degradation 3.6%, battery health 96.4%, 125 charges and 45 charging cycles, charging efficiency 93.9%, and a chart of battery capacity by mileage
Battery health: 3.6% estimated degradation, stable over the last 10,000 km.
  • Usable capacity: 58.7 kWh when new, 56.6 kWh now.
  • Battery health 96.4%, or about 3.6% estimated degradation at 45,773 km on the odometer.
  • 45 full charging cycles in my ownership, and a charging efficiency of 93.9%: the energy that goes into the battery compared with what’s taken from the grid.

The capacity line wobbles up and down: that’s how battery estimates work, and why you need months of data, not one reading. The trend is what matters, and here it’s flat. If I ever sell the car, this chart is worth more than any promise.

And because it’s the engineering mindset: these are the numbers behind the running-cost chart in Dare, then calculate. Not estimates, measurements.

How do I know all these numbers? Because I have the information. My data. And when you have information, you know.

How it works

Four containers work together:

  • TeslaMate asks Tesla’s servers for the car’s data and listens to its live stream while you drive. It’s careful to let the car fall asleep when parked, so logging doesn’t drain the battery.
  • PostgreSQL, the database, stores everything.
  • Grafana draws the dashboards.
  • Mosquitto, a small MQTT broker, publishes the live values for other systems, such as Home Assistant.

Which Tesla API?

TeslaMate uses the Owner API, the same one the Tesla app has always used. You sign in once with tokens from your Tesla account. Tesla has been moving third parties to its official Fleet API, and has already shut the old API for business fleet accounts. For private owners, the Owner API still works today. If that changes, TeslaMate’s documentation lists alternatives that use the official API, some of them free.

Your data stays yours

Your car’s history includes every place you’ve been, at what time, every day. That’s some of the most personal data you own. With TeslaMate, it goes from the car to Tesla (which has it anyway) and from Tesla straight to your NAS. Nobody else gets a copy, nobody analyses it, and nobody can change the terms or the price next year.

The flip side: you’re the one responsible for backups. The guide covers that too.

What you need

  • A Synology that runs Container Manager, with Portainer installed: see part one. I run it on a DS1621+.
  • About 1 GB of free RAM (2 GB is comfortable).
  • Your Tesla account and the Auth app for Tesla on your iPhone or Mac, to create the tokens. On other systems, the open-source tesla_auth tool does the same.

Step 1: create the two secrets

TeslaMate needs two secrets. Generate both with a password manager, or in a Mac terminal:

openssl rand -hex 32   # the encryption key
openssl rand -hex 16   # the database password
  • The encryption key protects your Tesla tokens inside the database.
  • The database password is used by TeslaMate and Grafana to reach PostgreSQL.

Store both in your password manager. Never use example values from any guide, including this one.

Step 2: deploy the stack in Portainer

  1. In Portainer, open Stacks → Add stack and name it teslamate.
  2. Paste this into the Web editor:
services:
  teslamate:
    image: teslamate/teslamate:latest
    container_name: teslamate
    restart: always
    environment:
      - ENCRYPTION_KEY=${ENCRYPTION_KEY}
      - DATABASE_USER=teslamate
      - DATABASE_PASS=${DATABASE_PASS}
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=database
      - MQTT_HOST=mosquitto
      - TZ=Europe/Zurich
    ports:
      - 4000:4000
    cap_drop:
      - all

  database:
    image: postgres:18-trixie
    container_name: teslamate-db
    restart: always
    environment:
      - POSTGRES_USER=teslamate
      - POSTGRES_PASSWORD=${DATABASE_PASS}
      - POSTGRES_DB=teslamate
    volumes:
      - teslamate-db:/var/lib/postgresql

  grafana:
    image: teslamate/grafana:latest
    container_name: teslamate-grafana
    restart: always
    environment:
      - DATABASE_USER=teslamate
      - DATABASE_PASS=${DATABASE_PASS}
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=database
    ports:
      - 3000:3000
    volumes:
      - teslamate-grafana-data:/var/lib/grafana

  mosquitto:
    image: eclipse-mosquitto:2
    container_name: teslamate-mosquitto
    restart: always
    command: mosquitto -c /mosquitto-no-auth.conf
    volumes:
      - mosquitto-conf:/mosquitto/config
      - mosquitto-data:/mosquitto/data

volumes:
  teslamate-db:
  teslamate-grafana-data:
  mosquitto-conf:
  mosquitto-data:
  1. Below the editor, under Environment variables, add ENCRYPTION_KEY and DATABASE_PASS with the two secrets from step 1. That way the secrets never sit in the stack text.
  2. Click Deploy the stack. The first start takes a minute while the images download.

A few choices in this file, and why:

  • Docker volumes, not shared folders. The database and dashboards live in Docker’s own volumes. You don’t need to create folders, and you never have to give the “Everyone” group write access to anything, which some guides do. Backups are covered in step 6.
  • TZ=Europe/Zurich: otherwise times are logged in UTC. Use your own time zone.
  • cap_drop: all: TeslaMate runs with the fewest rights possible.
  • Mosquitto without a published port: only the containers in this stack can reach it.
  • Ports 4000 and 3000: if something on your NAS already uses one of them, change the left number only, for example 4001:4000.

Step 3: sign in to TeslaMate with your tokens

  1. On your iPhone or Mac, open Auth app for Tesla and sign in with your Tesla account.
  2. It shows an access token and a refresh token. Treat them like your car key.
  3. Open http://YOUR-NAS-IP:4000, paste both tokens, and click Sign in.

Your car appears. From now on, TeslaMate refreshes the tokens by itself.

Step 4: the dashboards

  1. Open http://YOUR-NAS-IP:3000. Grafana asks for a login: admin / admin the first time.
  2. Set a new, strong password right away.
  3. Under Dashboards, you’ll find the TeslaMate folder with everything ready.

Step 5: settings worth changing

In TeslaMate, open Settings:

  • Units: kilometres, °C.
  • URLs: the Web App and Dashboards addresses. If you use the reverse proxy, enter https://teslamate.example.com and https://grafana.example.com; otherwise the IP and port.
  • Geo-fences: add Home (and work, if you charge there) with your price per kWh. From then on, every charging session there has a cost. That’s how you get real running costs instead of estimates.

Step 6: back up the database

The database is the treasure; everything else can be reinstalled in minutes. Make a weekly copy:

  1. In File Station, create the folder docker/teslamate-backup.
  2. In Control Panel → Task Scheduler, create a Scheduled Task → User-defined script, user root, weekly, with:
docker exec teslamate-db pg_dump -U teslamate teslamate > /volume1/docker/teslamate-backup/teslamate-$(date +%F).bck
  1. Include the backup folder in your normal NAS backup, for example Hyper Backup to an external disk or a second location.

Restoring is described in TeslaMate’s documentation. Test it once, before you need it.

Step 7: Home Assistant (optional)

TeslaMate publishes every value, like battery level, range, charging power, location state and doors, over MQTT. I feed these into Home Assistant, where they can drive automations and dashboards. The TeslaMate documentation has a ready-made Home Assistant configuration. More on my Home Assistant setup in Talos lives in my hallway.

Updating

TeslaMate is updated often. Before updating, read the release notes on GitHub: now and then a version needs an extra step, especially when the database moves to a new major version.

To update: in Portainer, open the teslamate stack, click Editor, then Update the stack with Re-pull image switched on.

Safety

  • Never open TeslaMate or Grafana to the internet. Behind TeslaMate are the tokens to your car. The project itself recommends a VPN; I use WireGuard, as described in Talos lives in my hallway.
  • Strong passwords for Grafana and Portainer.
  • Keep the tokens and secrets in a password manager, never in screenshots, chats or forum posts.

Was it worth it?

An hour of setup, once. In exchange: the complete history of my car, on my own disks, for no subscription, with dashboards that would make a fleet manager jealous. And the data is mine.

That’s the deal I like.