The Webcoast
Back to TeslaMate

Setting up TeslaMate

A multi-container setup: the logger itself, a database to log into, and a pre-built Grafana for viewing it.

  1. 1

    Set up the compose file

    TeslaMate needs its own Postgres database and pairs with a Grafana image that ships with its dashboards pre-loaded, no manual dashboard building needed.

    services:
      teslamate:
        image: teslamate/teslamate:latest
        container_name: teslamate
        restart: unless-stopped
        environment:
          - ENCRYPTION_KEY=change-this-to-something-random
          - DATABASE_USER=teslamate
          - DATABASE_PASS=change-this-too
          - DATABASE_NAME=teslamate
          - DATABASE_HOST=database
          - MQTT_HOST=mosquitto
        ports:
          - "4000:4000"
        volumes:
          - ./import:/opt/app/import
    
      database:
        image: postgres:16
        restart: unless-stopped
        environment:
          - POSTGRES_USER=teslamate
          - POSTGRES_PASSWORD=change-this-too
          - POSTGRES_DB=teslamate
        volumes:
          - ./teslamate-db:/var/lib/postgresql/data
    
      grafana:
        image: teslamate/grafana:latest
        restart: unless-stopped
        environment:
          - DATABASE_USER=teslamate
          - DATABASE_PASS=change-this-too
          - DATABASE_NAME=teslamate
          - DATABASE_HOST=database
        ports:
          - "3001:3000"
        volumes:
          - ./teslamate-grafana:/var/lib/grafana
  2. 2

    Start it and connect the car

    Once running, reach TeslaMate at port 4000 and follow its own sign-in flow, which authenticates against the Tesla account directly to start pulling vehicle data.

    docker compose up -d
  3. 3

    Let it log a drive or two

    Data starts appearing after the car's next drive or charge, TeslaMate polls the Tesla API on its own schedule rather than needing anything triggered manually.

  4. 4

    View the dashboards

    Grafana at port 3001 already has TeslaMate's dashboards imported and pointed at the right database, no data source setup required.

Further reading