Skip to main content

Manual install (Debian)

This document provides the necessary steps for installation of TeslaMate on a vanilla Debian or Ubuntu system. The recommended and most straightforward installation approach is through the use of Docker, however this walkthrough provides the necessary steps for manual installation in an aptitude (Debian/Ubuntu) environment.


Click on the following items to view detailed installation steps.

Postgres (v12+)
wget --quiet -O - | sudo apt-key add -echo "deb `lsb_release -cs`-pgdg main" | sudo tee  /etc/apt/sources.list.d/pgdg.listsudo apt-get updatesudo apt-get install -y postgresql-12 postgresql-client-12


Elixir (v1.11+)
wget && sudo dpkg -i erlang-solutions_2.0_all.debsudo apt-get updatesudo apt-get install -y elixir esl-erlang


Grafana (v7.2+) & Plugins
sudo apt-get install -y apt-transport-https software-properties-commonsudo add-apt-repository "deb stable main"wget -q -O - | sudo apt-key add -sudo apt-get updatesudo apt-get install -y grafanasudo systemctl start grafana-serversudo systemctl enable grafana-server.service # to start Grafana at boot time


Install the required Grafana plugins as well:

sudo grafana-cli plugins install pr0ps-trackmap-panelsudo grafana-cli plugins install natel-discrete-panelsudo grafana-cli plugins install grafana-piechart-panelsudo grafana-cli --pluginUrl plugins install grafana-worldmap-panel-ngsudo systemctl restart grafana-server

Import the Grafana dashboards after cloning the TeslaMate git repository.

An MQTT Broker (e.g. Mosquitto)
sudo apt-get install -y mosquitto


Node.js (v14+)
curl -sL | sudo -E bash -sudo apt-get install -y nodejs


Clone TeslaMate git repository#

The following command will clone the source files for the TeslaMate project. This should be run in an appropriate directory within which you would like to install TeslaMate. You should also record this path and provide them to the startup scripts proposed at the end of this guide.

cd /usr/src
git clone teslamate
git checkout $(git describe --tags `git rev-list --tags --max-count=1`) # Checkout the latest stable version

Create PostgreSQL database#

The following commands will create a database called teslamate on the PostgreSQL database server, and a user called teslamate. When creating the teslamate user, you will be prompted to enter a password for the user interactively. This password should be recorded and provided as an environment variable in the startup script at the end of this guide.

sudo -u postgres psqlpostgres=# create database teslamate;postgres=# create user teslamate with encrypted password 'secret';postgres=# grant all privileges on database teslamate to teslamate;postgres=# ALTER USER teslamate WITH SUPERUSER;postgres=# \q

Note: The superuser privileges can be revoked after running the initial database migrations.

Compile Elixir Project#

mix local.hex --force; mix local.rebar --force
mix deps.get --only prodnpm install --prefix ./assets && npm run deploy --prefix ./assets
MIX_ENV=prod mix do phx.digest, release --overwrite

Set your system locale#

You may need to set your system locale. If you get an error when running the TeslaMate service which indicates that you don't have a UTF-8 capable system locale set, run the following commands to set the locale on your system:

sudo locale-gen en_US.UTF-8sudo localectl set-locale LANG=en_US.UTF-8

Starting TeslaMate at boot time#

Create a systemd service at /etc/systemd/system/teslamate.service:

[Service]Type=simple# User=username# Group=groupname
ExecStartPre=/usr/src/teslamate/_build/prod/rel/teslamate/bin/teslamate eval "TeslaMate.Release.migrate"ExecStart=/usr/src/teslamate/_build/prod/rel/teslamate/bin/teslamate startExecStop=/usr/src/teslamate/_build/prod/rel/teslamate/bin/teslamate stop
  • MQTT_HOST should be the IP address of your MQTT broker. If you do not have one installed, the MQTT functionality can be disabled with DISABLE_MQTT=true.
  • TZ should be your local timezone. Work out your timezone name using the TZ database name in the linked Wikipedia page.

Start the service:

sudo systemctl start teslamate

And automatically get it to start on boot:

sudo systemctl enable teslamate

Import Grafana Dashboards#

  1. Visit localhost:3000 and log in. The default credentials are: admin:admin.

  2. Create a data source with the name "TeslaMate":

    Type: PostgreSQLDefault: YESName: TeslaMateHost: localhostDatabase: teslamateUser: teslamate  Password: secretSSL-Mode: disableVersion: 10
  3. Manually import the dashboard files or use the script:

    $ ./grafana/ restore
    URL:                  http://localhost:3000LOGIN:                admin:adminDASHBOARDS_DIRECTORY: ./grafana/dashboards
    RESTORED locations.jsonRESTORED drive-stats.jsonRESTORED updates.jsonRESTORED drive-details.jsonRESTORED charge-details.jsonRESTORED states.jsonRESTORED overview.jsonRESTORED vampire-drain.jsonRESTORED visited.jsonRESTORED drives.jsonRESTORED projected-range.jsonRESTORED charge-level.jsonRESTORED charging-stats.jsonRESTORED mileage.jsonRESTORED charges.jsonRESTORED efficiency.json

    To use credentials other than the default, set the LOGIN variable:

    LOGIN=user:password ./grafana/ restore