3.7 KiB
Tesla Fleet API Skill — Setup Guide
This guide covers setup + configuration for the Tesla Fleet API skill.
If you just want the CLI command reference, see SKILL.md.
Prerequisites
- Tesla Developer Account + an app created
- A domain you control (for public key hosting + virtual key enrollment)
python3- macOS (scripts tested on macOS)
State / Files
All runtime state lives outside the skill folder:
~/.bot/tesla-fleet-api/
Files:
.env— provider creds (client id/secret) and optional overridesconfig.json— non-token config (audience/base_url/ca_cert/redirect_uri/domain)auth.json— tokens (access/refresh)vehicles.json— cached vehicle listplaces.json— named locations ({"home": {"lat": ..., "lon": ...}})
1) Install + setup Tesla proxy (one-time)
Some commands require Tesla’s end-to-end signing via the local proxy.
cd skills/tesla-fleet-api
./scripts/setup_proxy.sh
This builds tesla-http-proxy and generates TLS material under:
~/.bot/tesla-fleet-api/proxy/
2) Create & host your EC keypair
# Generate P-256 keypair
openssl ecparam -name prime256v1 -genkey -noout -out private-key.pem
openssl ec -in private-key.pem -pubout -out public-key.pem
# Host public key at:
# https://YOUR_DOMAIN/.well-known/appspecific/com.tesla.3p.public-key.pem
Store your private key securely (recommended location):
~/.bot/tesla-fleet-api/YOUR_DOMAIN.tesla.private-key.pem
3) Put provider credentials into .env
Create:
~/.bot/tesla-fleet-api/.env
cat > ~/.bot/tesla-fleet-api/.env <<'EOF'
TESLA_CLIENT_ID=YOUR_CLIENT_ID
TESLA_CLIENT_SECRET=YOUR_CLIENT_SECRET
EOF
chmod 600 ~/.bot/tesla-fleet-api/.env
Optional overrides you can also set in .env:
TESLA_AUDIENCE(defaults to EU)TESLA_REDIRECT_URI(default:http://localhost:18080/callback)TESLA_DOMAINTESLA_BASE_URLTESLA_CA_CERT
4) Configure non-secret settings (optional)
python3 scripts/auth.py config set \
--redirect-uri "http://localhost:18080/callback" \
--audience "https://fleet-api.prd.eu.vn.cloud.tesla.com"
5) OAuth login (creates auth.json)
Interactive login (manual code paste):
python3 scripts/auth.py login
Automatic login via local callback server:
python3 scripts/tesla_oauth_local.py --prompt-missing-scopes
6) Register domain + enroll virtual key
python3 scripts/auth.py register --domain YOUR_DOMAIN.com
Then, on your phone (Tesla app installed):
https://tesla.com/_ak/YOUR_DOMAIN.com
7) Start proxy + configure scripts to use it
Start the proxy:
./scripts/start_proxy.sh ~/.bot/tesla-fleet-api/YOUR_DOMAIN.tesla.private-key.pem
Configure the scripts to talk to the local proxy:
python3 scripts/auth.py config set \
--base-url "https://localhost:4443" \
--ca-cert "$HOME/.bot/tesla-fleet-api/proxy/tls-cert.pem"
8) Test
python3 scripts/vehicles.py
python3 scripts/vehicle_data.py -c
python3 scripts/command.py honk
Places (named lat/lon)
# list
python3 scripts/command.py places list
# set explicit coords
python3 scripts/command.py places set home --lat 48.10033 --lon 17.04217
# set from current vehicle location
python3 scripts/command.py places set school --here
# use in precondition
python3 scripts/command.py precondition add -t 08:00 -d weekdays --place home
Troubleshooting
-
Token expired (401):
python3 scripts/auth.py refresh -
Vehicle asleep / unavailable:
python3 scripts/command.py wake -
Command not signed / rejected: ensure proxy is running and
base_url+ca_certare configured.