Skip to content

Unofficial CLI for Tesla Fleet API — control and monitor your Tesla from the terminal

License

Notifications You must be signed in to change notification settings

lu-zhengda/tesla-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tesla-cli

An unofficial command-line interface for the Tesla Fleet API — control your Tesla from the terminal.

Note: This tool communicates only with the official Tesla Fleet API. It does not collect, transmit, or store any personal data beyond what is necessary to authenticate with Tesla on your behalf.

Features

  • 🔑 Token-based authentication (OAuth2 refresh flow)
  • 🚗 List vehicles on your account
  • 📊 View vehicle status (battery, climate, locks, location, odometer)
  • 🔓 Lock / Unlock doors
  • ❄️ Climate on / off
  • ⚡ Start / Stop charging
  • 🌅 Wake vehicle
  • 🔄 Heartbeat — refresh access token automatically

Privacy & Data

  • No personal data is included in this repository (no API keys, email addresses, or account-specific configuration).
  • No user data is uploaded or shared with any service other than the official Tesla Fleet API.
  • All sensitive credentials are stored locally only, in:
    • ~/.tesla-cli/config.json — your Tesla application Client ID and VIN
    • ~/.tesla-cli/tokens.json — OAuth access/refresh tokens (mode 0600)

Installation

Requires Go 1.23+.

git clone https://github.com/lu-zhengda/tesla-cli.git
cd tesla-cli
go build -o tesla ./cmd/tesla

Move the binary to a directory on your $PATH if desired:

mv tesla /usr/local/bin/tesla
# or: install it to ~/bin/tesla

Setup

  1. Register a Tesla Developer Application at https://developer.tesla.com/
  2. Obtain an OAuth access token and refresh token via the Tesla authorization flow.
  3. Create the config directory and populate config files:
mkdir -p ~/.tesla-cli

# config.json — your app credentials and VIN
cat > ~/.tesla-cli/config.json << 'EOF'
{
  "client_id": "YOUR_CLIENT_ID",
  "vin": "YOUR_VIN"
}
EOF
chmod 600 ~/.tesla-cli/config.json

# tokens.json — your OAuth tokens
cat > ~/.tesla-cli/tokens.json << 'EOF'
{
  "access_token": "YOUR_ACCESS_TOKEN",
  "refresh_token": "YOUR_REFRESH_TOKEN"
}
EOF
chmod 600 ~/.tesla-cli/tokens.json

Usage

# List vehicles
tesla vehicles

# Vehicle status
tesla status

# Wake the vehicle
tesla wake

# Lock / Unlock
tesla lock
tesla unlock

# Climate
tesla climate-on
tesla climate-off

# Charging
tesla charge-start
tesla charge-stop

# Refresh token (run periodically or via cron)
tesla heartbeat

JSON Output

All commands support --json for scripting:

tesla status --json | jq '.battery_level'
tesla vehicles --json

Token Refresh

Access tokens expire. Run tesla heartbeat to refresh automatically using your stored refresh token:

# Manual refresh
tesla heartbeat

# Cron (every 6 hours)
0 */6 * * * /usr/local/bin/tesla heartbeat

Project Structure

tesla-cli/
├── cmd/tesla/         # main entrypoint
├── internal/
│   ├── api/           # Tesla Fleet API client
│   ├── cmd/           # CLI commands (Cobra)
│   └── config/        # Config & token loading/saving
├── go.mod
└── go.sum

Disclaimer

See DISCLAIMER.md for legal notices, warranty disclaimer, and Terms of Service requirements.

Security

See SECURITY.md for credential storage policy and how to report vulnerabilities.

License

MIT

About

Unofficial CLI for Tesla Fleet API — control and monitor your Tesla from the terminal

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages