Sharing your ETA with TeslaETA
One of my favourite features of Uber has always been "Share My ETA", a way to simply send a link to someone allowing them to see your estimated arrival time and track your ride. As I'm already running TeslaLogger, I thought I'd build a tool that would allow me to share my ETA based on my Tesla's location.
This is where TeslaETA comes in.
So how do you get it up and running alongside TeslaLogger?
TeslaETA behind Traefik
We'll assume you have a running Traefik and TeslaLogger instance, if not, you can use the following guide to get that set up.
We'll run TeslaETA as a Docker contianer, for which we'll need to configure 2 things, our docker-compose.yml
and the .env
file.
docker-compose.yml
We'll need to create a folder to store the SQLite DB in: mkdir -p ~/docker/teslaeta/data/
Next, we'll move into the folder cd ~/docker/teslaeta/
.
In that folder, let's create the following docker-compose.yml
file:
version: '3'
services:
teslaeta:
container_name: teslaeta
image: ghcr.io/flosoft/teslaeta:latest
volumes:
- ./data/:/data/
env_file:
- .env
networks:
- traefik_default
labels:
- "traefik.enable=true"
- "traefik.http.routers.teslaeta.rule=Host(`tesla.foo.bar`) && PathPrefix(`/map`)"
- "traefik.http.routers.teslaeta.entrypoints=websecure"
- "traefik.http.routers.teslaeta.tls=true"
- "traefik.http.routers.teslaeta.tls.certresolver=leresolver"
- "traefik.http.services.teslaeta.loadbalancer.server.port=5051"
- "traefik.docker.network=traefik_default"
networks:
traefik_default:
external: true
We'll mount the data
folder that we created as a volume, so that we can keep our SQLite database safe and connect it to the traefik_default
network.
Next, we'll configure the labels
. The configuration above will have it run on tesla.foo.bar/map
, and leverages leresolver
to generate certificates.
It's also expecting our TeslaETA service to run on 5051
.
.env
Now that we have the docker-compose file ready, let's configure the .env
file.
We'll use the .env_sample
file as a starting off point: https://github.com/flosoft/TeslaETA/blob/master/.env_sample
PORT=5051
DATA_DIR=/data/
SECRET_KEY=SOME_SECRET_KEY_HERE
ADMIN_PASSWORD=HTPASSWD_FOR_ADMIN_PASSWORD
BASE_URL=/map
MAPBOX_TOKEN=YOUR_MAPBOX_PUBLIC_KEY
TESLALOGGER_BASEURL=http://teslalogger:5000/
TESLALOGGER_CARID=1
TZ=Europe/Berlin
We'll configure the following variables:
PORT
will need to match your docker-compose configuration, so we'll set it to5051
.DATA_DIR
will need to match the volume mount, so we'll use/data/
here.SECRET_KEY
is a random key that's used to encrypt the user password. Just use a randomly generated password here.ADMIN_PASSWORD
is a htpasswd. You can use a command such ashtpasswd -n user
to generate a password. Just copy the password hash, not the username.BASE_URL
we'll set to/map
to match the Traefik rule.MAPBOX_TOKEN
you can get by creating a free account on Mapbox, and generating a token.TESLALOGGER_BASEURL
we'll set tohttp://teslalogger:5000/
as that's the internal service name on thetraefik_default
network and the 5000 port is the internal port used by TeslaLogger. If you're running TeslaLogger separately, simply point it to your TeslaLogger instance, i.e.http://raspberry:5010/
TESLALOGGER_CARID
is the ID of your car in TelsaLogger - the default being1
.TZ
is the environment variable you can use to set your local timezone for the expiry time of the links.
Running it all
Now that you've configured everything, simply use docker-compse up -d
to get it up and running.
That's it - you should now be able to access TeslaETA via https://tesla.foo.bar/map/admin
and create links.