| name | tesla-commander |
| description | Command and monitor Tesla vehicles via the Fleet API. Check status, control climate/charging/locks, track location, and analyze trip history. |
Tesla Commander
What Is This?
A command-line interface for Tesla vehicle owners. Query your car's status, control climate and charging, lock/unlock doors, track location, and review trip history — all from a terminal or automation script.
Built on the Tesla Fleet API (the official successor to the Owner API).
Before You Start
Authentication
Tesla Fleet API uses OAuth 2.0. You need:
- Client ID & Secret — Register an application at developer.tesla.com
- Access Token — Obtained via OAuth flow
- Vehicle ID — Your car's API identifier
export TESLA_ACCESS_TOKEN="eyJ..."
export TESLA_VIN="5YJ3E1EA1NF000000"
export TESLA_CLIENT_ID="your-client-id"
export TESLA_CLIENT_SECRET="your-secret"
Token Management
The script includes built-in token refresh:
bash scripts/tesla-cmd.sh auth login
bash scripts/tesla-cmd.sh auth refresh
bash scripts/tesla-cmd.sh auth check
Command Categories
1. Vehicle Status
Get a comprehensive snapshot of your vehicle's current state.
bash scripts/tesla-cmd.sh status
bash scripts/tesla-cmd.sh status battery
bash scripts/tesla-cmd.sh status climate
bash scripts/tesla-cmd.sh status drive
bash scripts/tesla-cmd.sh status vehicle
bash scripts/tesla-cmd.sh summary
2. Location & Tracking
bash scripts/tesla-cmd.sh location
bash scripts/tesla-cmd.sh location --map
bash scripts/tesla-cmd.sh track 30
bash scripts/tesla-cmd.sh distance "123 Main St, City, State"
3. Climate Control
bash scripts/tesla-cmd.sh climate on
bash scripts/tesla-cmd.sh climate off
bash scripts/tesla-cmd.sh climate temp 72
bash scripts/tesla-cmd.sh climate temp 22 --celsius
bash scripts/tesla-cmd.sh climate seat driver 2
bash scripts/tesla-cmd.sh climate seat passenger 1
bash scripts/tesla-cmd.sh climate seat rear-left 3
bash scripts/tesla-cmd.sh climate wheel on
bash scripts/tesla-cmd.sh climate defrost on
bash scripts/tesla-cmd.sh climate dog on
bash scripts/tesla-cmd.sh climate camp on
4. Charging
bash scripts/tesla-cmd.sh charge status
bash scripts/tesla-cmd.sh charge start
bash scripts/tesla-cmd.sh charge stop
bash scripts/tesla-cmd.sh charge limit 80
bash scripts/tesla-cmd.sh charge port open
bash scripts/tesla-cmd.sh charge port close
bash scripts/tesla-cmd.sh charge schedule 23:00
bash scripts/tesla-cmd.sh charge schedule off
5. Security & Access
bash scripts/tesla-cmd.sh lock
bash scripts/tesla-cmd.sh unlock
bash scripts/tesla-cmd.sh trunk open
bash scripts/tesla-cmd.sh frunk open
bash scripts/tesla-cmd.sh flash
bash scripts/tesla-cmd.sh honk
bash scripts/tesla-cmd.sh sentry on
bash scripts/tesla-cmd.sh sentry off
bash scripts/tesla-cmd.sh valet on 1234
bash scripts/tesla-cmd.sh valet off 1234
bash scripts/tesla-cmd.sh speedlimit set 65 1234
bash scripts/tesla-cmd.sh speedlimit clear 1234
6. Trip History & Analytics
bash scripts/tesla-cmd.sh trips 7
bash scripts/tesla-cmd.sh trips summary --month
bash scripts/tesla-cmd.sh trips charges 30
bash scripts/tesla-cmd.sh trips export trips_march.csv
bash scripts/tesla-cmd.sh efficiency
Automation Examples
Morning pre-conditioning (cron):
30 7 * * 1-5 bash /path/to/tesla-cmd.sh climate on && bash /path/to/tesla-cmd.sh climate temp 72
Low battery alert:
BATTERY=$(bash scripts/tesla-cmd.sh status battery --raw)
if [ "$BATTERY" -lt 20 ]; then
echo "Tesla battery at ${BATTERY}%!" | mail -s "Low Battery" you@email.com
fi
Geo-fence check:
bash scripts/tesla-cmd.sh location --raw | python3 -c "
import sys, json
data = json.load(sys.stdin)
lat, lon = data['latitude'], data['longitude']
# Check if within home radius
HOME_LAT, HOME_LON = 37.7749, -122.4194
dist = ((lat - HOME_LAT)**2 + (lon - HOME_LON)**2) ** 0.5
if dist > 0.01:
print('Vehicle is away from home')
"
Rate Limits & Considerations
- Tesla Fleet API enforces rate limits — the script includes automatic backoff
- Vehicle must be "awake" for most commands; the script handles wake-up automatically
- Wake-up can take 10-30 seconds; use
--nowait to skip waiting
- Frequent polling drains the 12V battery; keep polling intervals above 5 minutes for parked vehicles
Privacy & Security
- Access tokens are stored in
~/.tesla-commander/ with 600 permissions
- All communication uses TLS 1.2+
- The script never logs your token to stdout
- Consider using a separate Tesla account with limited vehicle access for shared scripts