Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

TeslaMate: Yet another self-hosted data logger for your Tesla

This site may earn commission on affiliate links.
I finally got it working after digging through various sections of the github and doing some research on various commands and the synology (it's been a few years since I did any heavy linux programming, so some of the issues were me tracking down commands). Below are my "idiot proof" instructions for how to get this running on a home LAN with a synology and a Windows10 PC.

  1. Login to your Synology, go to the package center and install Docker
  2. Open your windows notepad and create your docker-compose.yml file. It should look like:
    version: '3'
    services:
    teslamate:
    image: teslamate/teslamate:latest
    restart: unless-stopped
    environment:
    - DATABASE_USER=teslamate
    - DATABASE_PASS=secret
    - DATABASE_NAME=teslamate
    - DATABASE_HOST=db
    - MQTT_HOST=mosquitto
    - VIRTUAL_HOST=localhost # if you're going to access the UI from another machine replace
    # "localhost" with the hostname / IP address of the docker host.
    - TZ=Europe/Berlin # (optional) replace to use local time in debug logs. See "Configuration".
    ports:
    - 4000:4000
    cap_drop:
    - all

    db:
    image: postgres:11
    environment:
    - POSTGRES_USER=teslamate
    - POSTGRES_PASSWORD=secret
    volumes:
    - teslamate-db:/var/lib/postgresql/data

    grafana:
    image: teslamate/grafana:latest
    environment:
    - DATABASE_USER=teslamate
    - DATABASE_PASS=secret
    - DATABASE_NAME=teslamate
    - DATABASE_HOST=db
    ports:
    - 3000:3000
    volumes:
    - teslamate-grafana-data:/var/lib/grafana

    mosquitto:
    image: eclipse-mosquitto:1.6
    ports:
    - 1883:1883
    - 9001:9001
    volumes:
    - mosquitto-conf:/mosquitto/config
    - mosquitto-data:/mosquitto/data

    volumes:
    teslamate-db:
    teslamate-grafana-data:
    mosquitto-conf:
    mosquitto-data:
  3. Now edit the file as follows:
    1. change localhost in the VIRTUAL_Host line to whatever the local LAN IP address is for your synology (hopefully you have set your router to make that a static IP address). Should be something like 192.168.1.XXX
    2. change the TZ to equal the timezone where your synology resides. A list of the time zone codes that work can be found at List of tz database time zones - Wikipedia.
  4. Now save the file to your computer. It may be that Windows saves it as docker-compose.yml.txt. I had to go in and manually rename it, deleting the .txt part. It asked me if I wanted to change the file type and I said yes. No impact on it after that and I could still open it up with notepad.
  5. Now you need to transfer the file to Synology. If you can FTP to your synology, it's easy. If not, do the following:
    1. Open "File Station" in the Synology desktop.
    2. Navigate to a folder that is easy to get to (say a top level folder like "files"
    3. Right click your mouse, select upload to and upload your file from your windows pc. It should now be sitting in your "files" directory (or wherever you put it).
  6. Next you need to set up your synology so you can SSH to it. If you have already done this, skip this step. Otherwise, go to Control Panel->Terminal & SNMP and in the Terminal tap, check the box to enable SSH Service, leave the default port of 22 selected.
  7. Now go back to your Windows box and open up an SSH terminal. In my box I did it by clicking the Windows and the X keys and then selecting Windows Powershell
  8. In the command prompt, I typed ssh admin@synologylocal address (I used ssh [email protected] but you should also be able to type ssh [email protected] (whatever your synology ip address is)).
  9. You will then get a prompt to enter the admin password. Type in the admin password for your synology and hit enter.
  10. You should get a display showing something like "admin@servername:/$" -- this is the synology SSH prompt.
  11. Type sudo -i (this changes you to root access to the synology box)
  12. You will get a password prompt...type in your admin password again
  13. You will now get a prompt that looks like root@servername:
  14. Now change directories to your docker directory. Type cd /volume1/@docker (note the @ before docker)
  15. Your prompt will now show root@servername:/volume1/@docker#
  16. Now it gets fun....you need to move your docker-compose.yml file to the @docker directory (which you can't access or see from the File Station synology app), so you need to move it via linux commands. The command to type is mv /volume1/files/docker-compose.yml /volume1/@docker/docker-compose.yml Note there is a space between mv and the first file location and between that location and the destination file location. In linux, everything is case-sensitive, so if your files directory is named "Files" then you need to write it that way.
  17. Type dir and, if you are successful, you will see docker-compose.yml in the current (@docker) directory.
  18. You've now done the hard stuff. Next you type the command to download and install the packages. The command is docker-compose up -d (note the space after compose and up and the space between up and -d. You DO NOT type .yml after docker-compose. If you did everything right, things will run and scroll for several minutes as it downloads multiple packages and installs them. At the very end you will get some "dones" and be back to your root@servername: prompt.
  19. Go back to your synology web interface and open the Docker app. In the overview tab you should see 4 containers running: docker_db_1, docker_grafana_1, docker_mosquito_1, and docker_teslamate_1.
  20. Now in your PC web browser, you want to type: synologyIP address:4000 (should be something like 192.168.0.123:4000). The TeslaMate interface will open. Type in your TESLA email address and password (just like when you login to the car app). It will open up a page which shows you the current status of your car. Note it defaults to kilometers and degrees C but you can change that on the settings page.
  21. Now in your PC web browser, type in synologyIP address:3000 (should be something like 192.168.0.123:3000. This will open up Grafana which is where you can see all the charts. Various charts are on the left. Most are blank until you do something with your car/time goes by, but it will start populating. If you click on the "position" chart, it should open a map with a red dot where your car currently is. If you can see that, it is getting data from the car!
Realize this is a long post but figured these instructions would be helpful to those with a Synology who have never done this kind of thing before. @addison - This is really a great piece of work. If desired, you can post these instructions somewhere on your github page as well (I didn't want to assume anything and post them there).
 
@addison - when trying to star some of the charts as favorites, grafana says you need to sign in to do that. I click the sign in button and enter "teslamate" as the username and "secret" as the password but it says the name/password are invalid. Any suggestions? Or is that something I should just stay away from?

log in as admin/admin, then make a new pw. Then you can star them.
 
Thank you!

Authentication is not part of this this project. When exposing Teslamate to the internet I recommend the use a "reverse-proxy". I'll need to write a guide on how to do this. But I haven't had time for this yet. If you just want to password protect Grafana, sign in with the default credentials and change the user password. Afterwards set the env variable " GF_AUTH_ANONYMOUS_ENABLED" to false.

Someone already started working on dashboard that is similar to the Tesla-apiscraper. But I mostly want to keep instantaneous and historical data separate (web UI vs Grafana). I'll add charging voltage/current to the web UI.

There is no way to add kWh rate yet.

Thanks! This looks absolutely great.

I know how to do reverse proxy and may consider it in the future but for now it lives on my internal LAN behind a VPN.

Also my miles seem to be set to ideal rather than rated. Any way to change that?

Thanks
 
  • Disagree
Reactions: Schrobz
SOooooooooo Nice!

It took me a couple of days to get docker running on my Windows machine and learn enough to download TeslaMate, start it, find its IP and get it running...but that's all on me! :)

I was running VisibleTesla for the better part of the last 4 years for my Model S, but it looks like TeslaMate won't suffer from VT's main drawback from a performance standpoint...VT showed a continuous timeline not separating drive & charge events...that of course and the fact the streaming API stopped working this past March.

REALLY GOOD WORK!!!
Many thanks!
 
@addison, you rock, after Tesla's servers outage last night, their servers remapped VID which made the application crash...and you released a fix for everyone that remapped everything cleanly! So the application is up and running again on my machine in less than 24 hours!

I'm noticing that during the outage, the 'state' graph extrapolates their prior state as if the cars were available. There should be a gap around 20h00 on the 2nd for about 4 hours.
Wouldn't it be better to show absence of data?

Just a thought.
TeslaAPI outage.PNG
 
I've tried to add this to Freenas and was unable.
Ive since tried to add this to a QNAp with docker using containers.

i get the following on the teslamate container:

18:20:19.050 [error] Could not create schema migrations table. This error usually happens due to the following:

* The database does not exist
* The "schema_migrations" table, which Ecto uses for managing
migrations, was defined by another library
* There is a deadlock while migrating (such as using concurrent
indexes with a migration_lock)

To fix the first issue, run "mix ecto.create".

To address the second, you can run "mix ecto.drop" followed by
"mix ecto.create". Alternatively you may configure Ecto to use
another table for managing migrations:

config :teslamate, TeslaMate.Repo,
migration_source: "some_other_table_for_schema_migrations"

Any help as to what im doing wrong appreciated.
In the docker-compose.yml file from the github site I changed only virtual host to my QNAP IP

Grafana starts fine, but says database teslamate does not exist
 
Thanks, it looks awesome, I got it running on a RPi 3 (Let me know if anyone wants the img for it)

How does the "Time to Try Sleeping" work? is that how long I want the logger to keep the car awake after a drive or is it how long it'll wait in between sleeping states to send a new request?
 
  • Like
Reactions: Morristhecat
Thanks, it looks awesome, I got it running on a RPi 3 (Let me know if anyone wants the img for it)

How does the "Time to Try Sleeping" work? is that how long I want the logger to keep the car awake after a drive or is it how long it'll wait in between sleeping states to send a new request?
Hi @L-P-G,
I would love to have an image for the raspberry pi. Can you please post it somewhere or PM me? Creating the image is beyond me, but working with it I can do. Much appreciated in advance!
 
Well done @addison!

I would also love to see someone publish a proper step-by-step guide on how to install on a Raspberry Pi or Ubuntu for instance. With proper and safe login authentication, so it can be used from the outside with port redirection.

Great initiative and definitely something I've been looking for a long time now!
 
I too was able to get this running just fine on QNAP NAS via ssh. Fantastic set up. After some time though, I’d like to compile an overlay graph of my charging data, specifically supercharging data. Is there a way to create a panel to plot charge rates vs % or miles remaining base on when supercharging is true?
 
I was thinking of making a pi image but im worried about the whole ip address thing. The script requires a known ip address to be set in the config.

Im running mine on ubuntu. Anyone know how to get "docker-compose up" command to run on start?

Having a surprisingly hard time for some reason.


On a side note. For those of you who have a ton of pis. I ended up setting a vmware esxi server and never looked back. Run as many operating systems as you want on one computer without the slowness of a pi