Kategorien
Software Technologie Tesla

Wie TeslaMate mit Docker eingerichtet wird

In this article I am going to walk you through step by step on how to install and setup TeslaMate auf Ihr Vultr Cloud Instance. From selecting your VM configuration to installing and configuring the tool onto your virtual machine. Looking for a guide on BuyVM? Klicken Sie hier.

In this tutorial, I use Vultr because they have an ideal way of setting up a docker server with their preset image and getting started very quickly. I also like if you aren’t happy with TeslaMate you can easily destroy the cloud instance and go on with your day. However, see how far you can take it with the $100 in free credits (must use credits within 30 days)!

| graydonschwartz.com

TeslaMate Merkmale:

  • Fahr- und Ladeberichte
  • Bericht über die Effizienz des Fahrens
  • Energieverbrauch (netto / brutto)
  • Aufladung Hinzugefügte Energie vs. verbrauchte Energie
  • Vampir-Drainage
  • Voraussichtliche Reichweite des 100% (Batterieverschleiß)
  • Auflade-Statistiken
  • Antriebsstatistiken
  • Historie der installierten Updates
  • Sehen Sie, wann Ihr Auto online war oder schlief
  • Lifetime Driving Map
  • Besuchte Adressen

ALSO überprüfen Sie den Status Ihres Fahrzeugs (inkl. Batteriestand), ohne Ihr Auto aufzuwecken!

We will be following the developers advanced instructions due to the fact that we will be using a cloud instance, alternatively, you could install this on a Rasberry Pi or an extra computer you had lying around. I however like this option with Vultr due to being easy to re-produce for just about anyone.

Deploy New Instance

vultrplus20200413 | graydonschwartz.com
Mouse over the (+) plus sign and click on Deploy New Server

Choose Server: Cloud Compute

vultrchooseservercloudcompute20200413 | graydonschwartz.com
How to Setup TeslaMate with Docker 23


Server Location: Chicago (I selected Chicago but you can select whatever is best for you):

  • Atlanta, USA
  • New York (NJ), USA
  • Chicago, USA
  • Dallas, USA
  • Los Angeles, USA
  • Miami, USA
  • Seattle, USA
  • Silicon Valley, USA
  • Toronto, CANADA
  • Amsterdam, Netherlands
  • Paris, France
  • Frankfurt, Germany
  • London, UK
  • Tokyo, Japan
  • Singapore, Singapore
  • Sydney, Australien

Server Type: Application: Docker: On CentOS 7 x64 19.03.4-ce

vultrservertypeappdocker20200413 | graydonschwartz.com
How to Setup TeslaMate with Docker 24

Server Size: 25 GB SSD
$5.00/mo OR $0.007/h
1 CPU
1024MB Memory*
1000GB Bandwidth

vultrserversize20200413 | graydonschwartz.com
How to Setup TeslaMate with Docker 25

*Note: Docker requires a plan with at least 768MB of memory.

Klicken Sie auf Deploy Now!

vultrdeploynow20200413 | graydonschwartz.com
How to Setup TeslaMate with Docker 26

Click on Products!

vultrproducts20200413 | graydonschwartz.com
How to Setup TeslaMate with Docker 27
vultryourproducts20200413 | graydonschwartz.com
How to Setup TeslaMate with Docker 28

Server Information

vultrserverinfodocker20200413 | graydonschwartz.com
How to Setup TeslaMate with Docker 29

Herunterladen PuTTY

Enter the IP Address
and click on Open!

GUIDE: Advanced Docker install (Traefik, Let’s Encrypt, HTTPS, HTTP Basic Auth)

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Einrichtung - docker-compose.yml

version: "3"

services:
  teslamate:
    image: teslamate/teslamate:latest
    restart: always
    depends_on:
      - database
    environment:
      - DATABASE_USER=${TM_DB_USER}
      - DATABASE_PASS=${TM_DB_PASS}
      - DATABASE_NAME=${TM_DB_NAME}
      - DATABASE_HOST=database
      - MQTT_HOST=mosquitto
      - VIRTUAL_HOST=${FQDN_TM}
      - CHECK_ORIGIN=true
      - TZ=${TM_TZ}
    volumes:
      - ./import:/opt/app/import
    labels:
      - "traefik.enable=true"
      - "traefik.port=4000"
      - "traefik.http.middlewares.redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.teslamate-auth.basicauth.realm=teslamate"
      - "traefik.http.middlewares.teslamate-auth.basicauth.usersfile=/auth/.htpasswd"
      - "traefik.http.routers.teslamate-insecure.rule=Host(`${FQDN_TM}`)"
      - "traefik.http.routers.teslamate-insecure.middlewares=redirect"
      - "traefik.http.routers.teslamate-ws.rule=Host(`${FQDN_TM}`) && Path(`/live/websocket`)"
      - "traefik.http.routers.teslamate-ws.entrypoints=websecure"
      - "traefik.http.routers.teslamate-ws.tls"
      - "traefik.http.routers.teslamate.rule=Host(`${FQDN_TM}`)"
      - "traefik.http.routers.teslamate.middlewares=teslamate-auth"
      - "traefik.http.routers.teslamate.entrypoints=websecure"
      - "traefik.http.routers.teslamate.tls.certresolver=tmhttpchallenge"
    cap_drop:
      - all

  database:
    image: postgres:13
    restart: always
    environment:
      - POSTGRES_USER=${TM_DB_USER}
      - POSTGRES_PASSWORD=${TM_DB_PASS}
      - POSTGRES_DB=${TM_DB_NAME}
    volumes:
      - teslamate-db:/var/lib/postgresql/data

  grafana:
    image: teslamate/grafana:latest
    restart: always
    environment:
      - DATABASE_USER=${TM_DB_USER}
      - DATABASE_PASS=${TM_DB_PASS}
      - DATABASE_NAME=${TM_DB_NAME}
      - DATABASE_HOST=database
      - GRAFANA_PASSWD=${GRAFANA_PW}
      - GF_SECURITY_ADMIN_USER=${GRAFANA_USER}
      - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PW}
      - GF_AUTH_ANONYMOUS_ENABLED=false
      - GF_SERVER_DOMAIN=${FQDN_TM}
      - GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s/grafana
      - GF_SERVER_SERVE_FROM_SUB_PATH=true

    volumes:
      - teslamate-grafana-data:/var/lib/grafana
    labels:
      - "traefik.enable=true"
      - "traefik.port=3000"
      - "traefik.http.middlewares.redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.grafana-insecure.rule=Host(`${FQDN_TM}`)"
      - "traefik.http.routers.grafana-insecure.middlewares=redirect"
      - "traefik.http.routers.grafana.rule=Path(`/grafana`) || PathPrefix(`/grafana/`)"
      - "traefik.http.routers.grafana.entrypoints=websecure"
      - "traefik.http.routers.grafana.tls.certresolver=tmhttpchallenge"

  mosquitto:
    image: eclipse-mosquitto:2
    restart: always
    command: mosquitto -c /mosquitto-no-auth.conf
    ports:
      - 127.0.0.1:1883:1883
    volumes:
      - mosquitto-conf:/mosquitto/config
      - mosquitto-data:/mosquitto/data

  proxy:
    image: traefik:v2.4
    restart: always
    command:
      - "--global.sendAnonymousUsage=false"
      - "--providers.docker"
      - "--providers.docker.exposedByDefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.tmhttpchallenge.acme.httpchallenge=true"
      - "--certificatesresolvers.tmhttpchallenge.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.tmhttpchallenge.acme.email=${LETSENCRYPT_EMAIL}"
      - "--certificatesresolvers.tmhttpchallenge.acme.storage=/etc/acme/acme.json"
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./.htpasswd:/auth/.htpasswd
      - ./acme/:/etc/acme/
      - /var/run/docker.sock:/var/run/docker.sock:ro

volumes:
  teslamate-db:
  teslamate-grafana-data:
  mosquitto-conf:
  mosquitto-data:

Einrichtung - .env

TM_DB_USER=teslamate
TM_DB_PASS=secret
TM_DB_NAME=teslamate

GRAFANA_USER=admin
GRAFANA_PW=admin

FQDN_TM=teslamate.example.com

TM_TZ=Europe/Berlin

LETSENCRYPT_EMAIL=yourperson@example.com

Einrichtung - .htpasswd

Wie in der Dokumentation zu TeslaMate beschrieben. Ich empfehle Ihnen, dieses Tool zu verwenden, um Ihre .htpasswd-Datei zu erstellen:
http://www.htaccesstools.com/htpasswd-generator/
Geben Sie Ihr gewünschtes Nutzername, Passwort und Bcrypt auswählen (ab Apache v2.4)
In dem folgenden Beispiel habe ich Folgendes eingegeben Nutzername und Passwort für diese Felder:

Beispiel:

my:$2y$10$as5PEnYaoGEx2ebCFjdK0e9PBshAsvzIeAKijwNgeMSC9oJkDNo2.

Kopieren Sie nun diese Informationen und fügen Sie sie in Ihre .htpasswd-Datei ein.

vi .htpasswd (oder Ihr bevorzugter Texteditor)

Stellen Sie sicher, dass Sie Ihr Passwort einrichten, bevor Sie das Teslamate mit Docker starten!

docker-compose aufwärts

Hinweis: Möglicherweise müssen Sie diesen Befehl zweimal ausführen, damit er funktioniert.



DNS-Einrichtung

You will need to point teslamate.example.com + grafana.exampe.com (your subdomain) to the IP Address provided to you by Vultr when you created your virtual server. This is done by contacting your web host or logging into your control panel to manage your DNS records and having these entries added.

Anmeldung bei TeslaMate

  1. Öffnen Sie die Weboberfläche https://teslamate.example.com
    Melden Sie sich mit den Daten an, die Sie in die .htpasswd-Datei eingegeben haben. Anschließend werden Sie aufgefordert, sich mit Ihrem Tesla-Konto anzumelden.
  2. Melden Sie sich mit Ihrem Tesla-Konto an
  3. Die Grafana Dashboards sind verfügbar unter: https://grafana.example.com.
  4. Geben Sie Benutzernamen und Passwort ein:admin:admin und Sie werden bei Ihrer ersten Anmeldung aufgefordert, das Passwort zu ändern.

I spent $0.01 or 1 penny to test out Teslamate. $0.02 to complete the tutorial. 🙂

vultrdockercloudinstance | graydonschwartz.com
Vultr Control Panel

You can change from Celcius to Fahrenheit and Kilometers to Miles in the settings.

teslamatehomescreenfeb212020 | graydonschwartz.com
TeslaMate Home Screen

This is what the home screen looks like. You would also see a map with a pin on the location of your Tesla vehicle.

teslamatehomescreencharging1kwfeb212020 | graydonschwartz.com
5 mi/hr | 12A | 3kW

I went for a charge session at the closest regular 12a outlet to show what a charge session looks like with TeslaMate. Clean interface! 🙂

teslamatehomescreencharging3kwfeb212020 | graydonschwartz.com
13 mi/hr | 16A | 3kW
teslamatecharginggraph3kwfeb212020 | graydonschwartz.com
13 mi/hr | 16A | 3kW

March 10, 2020 Update

TeslaMate released an update to v1.17.1 about 16 days ago.

  • Add Trip dashboard: This dashboard was built to visualize longer trips. It provides an overview of all drives and charges that were logged over a period of several hours or days.
  • TeslaMate Release Page

I am excited to test out this new Trip dashboard added in the new release. This will be super helpful for Tesla road trips of course! 🙂

This is the documentation I used to build portions of this tutorial:
https://docs.teslamate.org/docs/guides/traefik
https://docs.teslamate.org/docs/guides/portainer

March 21, 2020 Update

How to use the new trip feature apart of Teslamate:

  1. Öffnen Sie die Weboberfläche https://teslamate.example.com
  2. Dashboards => Tap or click on “Trip
  3. Tap or click on “Today so far
  4. Select preset from “Last 5 minutes“, all the way to “Last 5 years” or custom date range selection.
teslamatehomescreenmarch212020 | graydonschwartz.com
TeslaMate Home Screen
teslamatehomescreenmarch212020 1 | graydonschwartz.com
Tap or mouse over “Dashboards
teslamatehomescreenmarch212020 2 | graydonschwartz.com
Tap or click on “Trip
teslamatehomescreenmarch212020 3 | graydonschwartz.com
Select preset from “Last 5 minutes“, all the way to “Last 5 years” or custom date range selection.
teslamatetriplast1yearmarch212020 | graydonschwartz.com
TeslaMate > Trip Example
teslamatehomescreenmarch212020 4 | graydonschwartz.com
TeslaMate > Trip Example (Closeup)

Ich hoffe, Sie fanden diese Anleitung hilfreich 🙂 .

| graydonschwartz.com

Von Graydon Schwartz

Mehr über Graydon erfahren Sie auf der Website Über mich Seite.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.