Tesla

From mvanhorn/printing-press-library · View interactive version

Tesla is an AI agent skill from the GitHub repository mvanhorn/printing-press-library. Every Tesla mobile-app feature, plus a charging-cost ledger and supercharger queue watcher no other Tesla CLI ships. Trigger phrases: `is my tesla ready`, `precondition my tesla`, `how much did i spend on charging this month`, `supercharger queue at`, `send this address to my tesla`, `list my tesla

How to use this skill

Skill file

Tesla — Printing Press CLI

Prerequisites: Install the CLI

This skill drives the tesla-pp-cli binary. You must verify the CLI is installed before invoking any command from this skill. If it is missing, install it first:

  1. Install via the Printing Press installer. It defaults binaries to $HOME/.local/bin on macOS/Linux and %LOCALAPPDATA%\Programs\PrintingPress\bin on Windows:

```bash

npx -y @mvanhorn/printing-press-library install tesla --cli-only

```

  1. Verify: tesla-pp-cli --version
  2. Ensure the reported install directory is on $PATH for the agent/runtime that will invoke this skill.

If the npx install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.26.6 or newer):

go install github.com/mvanhorn/printing-press-library/library/devices/tesla/cmd/tesla-pp-cli@latest

If --version reports "command not found" after install, the runtime cannot see the binary directory on $PATH. Do not proceed with skill commands until verification succeeds.

When to Use This CLI

Use tesla-pp-cli when you want a JSON-first CLI for your Tesla owner account: vehicle state inspection, climate/lock/charge commands, charging cost analytics, and an MCP surface for AI agents to drive your car. Faster than the iOS app for one-off commands, more agent-friendly than TeslaPy, and ships a local SQLite that delivers TeslaMate-style analytics (drives, charges, vampire drain, cost ledger) without standing up Postgres+Grafana. Best fit for owners with pre-2021 Models S/X or 3/Y on the old REST endpoints; newer vehicles get a clear shim via tesla reachability.

Unique Capabilities

These capabilities aren't available in any other tool for this API.

Composite truth from local state

_Most-asked Tesla owner question; the iOS app makes it a 6-tap diagnostic, agents need a one-call truth_

```bash

tesla ready 5YJ3E1EA6XXXXXXXX --json

```

Local analytics that beat the dashboard

_Charging cost is the #1 Tesla-owner spreadsheet exercise; this is the first pure-CLI replacement for the TeslaMate dashboard_

```bash

tesla cost ledger --since 2026-04-01 --group supercharger --json

```

_Most Tesla owners suspect they could save by charging at home but lack proof; this puts a dollar figure on it_

```bash

tesla cost what-if --only-home --since 90d --json

```

_Lets agents reason over the same data TeslaMate exposes, without standing up Docker+Postgres+Grafana_

```bash

tesla timeline --since "last week" --json

```

_Warranty-dispute evidence and rogue-sentry detection; TeslaMate dashboard only otherwise_

```bash

tesla vampire --threshold 1.5pct/24h --since 30d --json

```

Charging intelligence nobody else exposes

_Avoids the I-90 Issaquah queue at peak; pageable from an agent on a drive_

```bash

tesla supercharger watch 1000 --free-stalls 2 --watch --json

```

Security audit nobody else does

_Security-minded owners worry about old phones and abandoned NFC cards still pairing with their car; this is the quarterly review_

```bash

tesla keys audit --stale-after 90d --json

```

Reachability mitigation

_Tesla's 2024-2026 signed-command rollout is the #1 user-facing landmine for any Tesla CLI; this is the only one that surfaces it clearly_

```bash

tesla doctor --json

```

Discovery Signals

This CLI was generated with browser-observed traffic context.

Command Reference

charging — Supercharger queue position and charging status

diagnostics — Vehicle diagnostic feature config

energy_sites — Powerwall and solar energy site config

logs — Client-side telemetry sink

notification_preferences — Push notification settings

products — Vehicles, Powerwalls, and solar products owned by the user

users — Account config, feature flags, orders, and key/credential management

vehicles — Per-vehicle data, climate, locks, remote start, and Hermes telemetry token

Finding the right command

When you know what you want to do but not which command does it, ask the CLI directly:

tesla-pp-cli which "<capability in your own words>"

which resolves a natural-language capability query to the best matching command from this CLI's curated feature index. Exit code 0 means at least one match; exit code 2 means no confident match — fall back to --help or use a narrower query.

Recipes

Snap then ready

tesla snap --all --json && tesla ready 5YJ3E1EA6XXXXXXXX --json

Capture vehicle state for every car on the account, then check whether your primary vehicle is ready to drive.

Morning ready check

tesla ready 5YJ3E1EA6XXXXXXXX --json --select ready,blockers

One JSON object: is the car ready to drive, and if not, why not. Use --select to limit response size for agents.

Monthly charging-cost report

tesla cost ledger --since 30d --group supercharger,home --json --select total_usd,sessions,kwh_added,supercharger_ratio

Per-month breakdown with dotted-path --select so the agent sees only the rollup fields, not every session.

Preconditioning before leaving

tesla vehicles create-auto-conditioning-start 5YJ3E1EA6XXXXXXXX --json

Start climate preconditioning. Run tesla ready <vin> ten minutes later to confirm cabin warmed up.

Supercharger queue watcher

tesla supercharger watch 1000 --free-stalls 2 --watch --json

Subscribe to free-stall transitions at a saved site; emits one JSON line per transition. Pipe to an agent for alerting.

Local SOC history via analytics

tesla-pp-cli analytics --select battery_level,captured_at --limit 30 --json

Pull the 30 most recent vehicle-state rows from the local SQLite for trend analysis; same data TeslaMate would surface in Grafana.

Recipe: Remote commands from anywhere (Fleet path — default)

# 1. Install tesla-control (clone+build, not go install @latest)
git clone https://github.com/teslamotors/vehicle-command.git
cd vehicle-command && go build -o tesla-control ./cmd/tesla-control
mv tesla-control ~/go/bin/ && cd ..

# 2. Generate keypair and scaffold public-key host
tesla-pp-cli auth fleet-template --gen-key --dest ./tesla-keys-host
cd tesla-keys-host && vercel deploy --prod

# 3. Register at developer.tesla.com with the Vercel hostname, copy client_id and client_secret

# 4. Register with Tesla (key-file auto-detected from ~/.tesla/)
tesla-pp-cli auth fleet-register \
  --public-key-domain <your-host>.vercel.app \
  --client-id <id> \
  --client-secret-file <secret-file>

# 5. User OAuth login
tesla-pp-cli auth fleet-login

# 6. ONE-TIME: Enroll virtual key at the car (BLE+NFC required, must be at car)
tesla-control -ble -vin <VIN> add-key-request owner cloud_key
# Tap NFC card or phone key when the car prompts

# 7. Now remote commands work from anywhere
tesla-pp-cli command climate_on --vehicle <name> --send
tesla-pp-cli command unlock --vehicle <name> --send

After the one-time BLE+NFC pairing at the car, all signed commands work from anywhere with internet. Per-call cost: $0.001 plus a $0.02 wake if the car is asleep. Inside the $10/mo personal-use credit, that lands at roughly $0 net.

Recipe: Switching between paths

The --via flag overrides the default transport:

tesla-pp-cli command set_charge_limit --vehicle <name> --send -- percent=80
tesla-pp-cli command unlock --vehicle <name> --send --via fleet
tesla-pp-cli command flash_lights --vehicle <name> --send --via ble
tesla-pp-cli command honk_horn --vehicle <name> --send --via hermes

Defaults: pre-2021 vehicles use REST, post-2021 vehicles use Fleet when enrolled. Use --via=hermes to force the Hermes relay path (free, but only for infotainment commands — charge, climate, honk, media). Use --via=ble for local Bluetooth commands.

Recipe: Deploy your tesla agent to a cloud Mac mini

# On laptop:
tesla auth export --out tesla-bundle.enc
scp tesla-bundle.enc user@mac-mini:~/

# On Mac mini:
tesla auth import ~/tesla-bundle.enc
tesla-pp-cli command honk_horn --vehicle <name> --send --via fleet

Export creates an Argon2id plus AES-256-GCM bundle of the REST bearer, the Fleet bearer, and the enrolled ECDSA keypair. Copy it over Tailscale or any secure channel. Import on the remote, enter the passphrase, and the same Fleet creds plus the same enrolled key work from the new host. The car does not need to re-enroll; key identity rides on the keypair.

Path-decision flowchart

Text form (rendered consistently across SKILL.md viewers):

Is the vehicle pre-2021?
  Yes -> REST (default path, no extra setup)
  No  -> Continue.

Is Fleet API enrolled?
  Yes -> Fleet API (default for all signed commands, roughly $0/mo within personal-use credit)
  No  -> Continue.

Is the car within Bluetooth range of this host?
  Yes -> BLE (free, all commands, no internet needed)
  No  -> Continue.

Is Hermes relay running and only need infotainment commands?
  Yes -> Hermes (free, but only charge/climate/honk/media — no unlock/lock/trunk)
  No  -> Set up Fleet API (see Auth Setup below)

Deploying to a second host (cloud Mac mini, Pi)?
  Use Fleet + `tesla auth export` and `tesla auth import` on the remote.

Auth Setup

Step 1: Install tesla_auth (required)

The CLI requires tesla_auth for OAuth login. Install it first:

cargo install tesla_auth
# or on macOS: brew install adriankumpf/tap/tesla_auth

Step 2: Owner API Login

tesla-pp-cli auth login

This subprocesses into tesla_auth, which opens Tesla's OAuth page in a native window. Log in there (Tesla owns MFA, captcha, SMS codes - we never see them), and tesla_auth captures the tokens. The CLI stores them in ~/.config/tesla-pp-cli/config.toml (mode 0600). Bearer tokens last 8h; the CLI silently re-mints them on 401 using the long-lived refresh token.

Headless/CI fallbacks when you already have a refresh token:

Step 3: For 2021+ Vehicles (Fleet API + Virtual Key)

2021+ Teslas require signed commands via the Fleet API. This is a one-time setup:

  1. Install tesla-control (clone and build — go install @latest fails due to upstream replace directives):

```bash

git clone https://github.com/teslamotors/vehicle-command.git

cd vehicle-command

go build -o tesla-control ./cmd/tesla-control

mv tesla-control ~/go/bin/ # or somewhere on your $PATH

```

  1. Scaffold public-key host and generate keypair:

```bash

tesla-pp-cli auth fleet-template --gen-key --dest ./tesla-keys-host

cd tesla-keys-host && vercel deploy --prod

```

  1. Register at developer.tesla.com: Create an app with allowed origin/redirect pointing to your deployed host and http://localhost:8585/callback. Copy the client_id and client_secret.
  1. Register with Tesla (the --key-file is auto-detected from ~/.tesla/):

```bash

tesla-pp-cli auth fleet-register \

--client-id <id> \

--client-secret-file <secret-path> \

--public-key-domain <your-host>.vercel.app

```

  1. Complete user OAuth:

```bash

tesla-pp-cli auth fleet-login

```

  1. Enroll virtual key at the car (BLE+NFC required — the car must be nearby):

```bash

tesla-control -ble -vin <VIN> add-key-request owner cloud_key

# Tap your NFC card or phone key when the car prompts

```

This step cannot be done remotely — you must be at the car with Bluetooth and an NFC credential.

Run tesla-pp-cli doctor to verify setup.

Agent Mode

Add --agent to any command. Expands to: --json --compact --no-input --no-color --yes.

```bash

tesla-pp-cli charging --agent --select id,name,status

```

Response envelope

Commands that read from the local store or the API wrap output in a provenance envelope:

{
  "meta": {"source": "live" | "local", "synced_at": "...", "reason": "..."},
  "results": <data>
}

Parse .results for data and .meta.source to know whether it's live or local. A human-readable N results (live) summary is printed to stderr only when stdout is a terminal AND no machine-format flag (--json, --csv, --compact, --quiet, --plain, --select) is set — piped/agent consumers and explicit-format runs get pure JSON on stdout.

Agent Feedback

When you (or the agent) notice something off about this CLI, record it:

tesla-pp-cli feedback "the --since flag is inclusive but docs say exclusive"
tesla-pp-cli feedback --stdin < notes.txt
tesla-pp-cli feedback list --json --limit 10

Entries are stored locally at ~/.tesla-pp-cli/feedback.jsonl. They are never POSTed unless TESLA_FEEDBACK_ENDPOINT is set AND either --send is passed or TESLA_FEEDBACK_AUTO_SEND=true. Default behavior is local-only.

Write what surprised you, not a bug report. Short, specific, one line: that is the part that compounds.

Output Delivery

Every command accepts --deliver <sink>. The output goes to the named sink in addition to (or instead of) stdout, so agents can route command results without hand-piping. Three sinks are supported:

| Sink | Effect |

|------|--------|

| stdout | Default; write to stdout only |

| file:<path> | Atomically write output to <path> (tmp + rename) |

| webhook:<url> | POST the output body to the URL (application/json or application/x-ndjson when --compact) |

Unknown schemes are refused with a structured error naming the supported set. Webhook failures return non-zero and log the URL + HTTP status on stderr.

Named Profiles

A profile is a saved set of flag values, reused across invocations. Use it when a scheduled agent calls the same command every run with the same configuration - HeyGen's "Beacon" pattern.

tesla-pp-cli profile save briefing --json
tesla-pp-cli --profile briefing charging
tesla-pp-cli profile list --json
tesla-pp-cli profile show briefing
tesla-pp-cli profile delete briefing --yes

Explicit flags always win over profile values; profile values win over defaults. agent-context lists all available profiles under available_profiles so introspecting agents discover them at runtime.

Exit Codes

| Code | Meaning |

|------|---------|

| 0 | Success |

| 2 | Usage error (wrong arguments) |

| 3 | Resource not found |

| 4 | Authentication required |

| 5 | API error (upstream issue) |

| 7 | Rate limited (wait and retry) |

| 10 | Config error |

Argument Parsing

Parse $ARGUMENTS:

  1. Empty, help, or --help → show tesla-pp-cli --help output
  2. Starts with install → ends with mcp → MCP installation; otherwise → see Prerequisites above
  3. Anything else → Direct Use (execute as CLI command with --agent)

MCP Server Installation

Install the MCP binary from this CLI's published public-library entry or pre-built release, then register it:

claude mcp add tesla-pp-mcp -- tesla-pp-mcp

Verify: claude mcp list

Direct Use

  1. Check if installed: which tesla-pp-cli

If not found, offer to install (see Prerequisites at the top of this skill).

  1. Match the user query to the best command from the Unique Capabilities and Command Reference above.
  2. Execute with the --agent flag:

```bash

tesla-pp-cli <command> [subcommand] [args] --agent

```

  1. If ambiguous, drill into subcommand help: tesla-pp-cli <command> --help.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.