mcpField
T
tesla-fleet-api

tesla-fleet-api

github.com/odrobnikその他0950 回インストール30 週間前に更新
リポジトリ

tesla-fleet-api について

Tesla Fleet APIを通じて車両情報の取得や操作を行うコマンドラインツールです。車両を管理するTeslaオーナー向けで、OAuth設定やトークン管理機能も備えています。

主な機能

  1. 01空調、シート、ステアリングヒーターの制御
  2. 02充電、ロックなどの操作
  3. 03車両状態と位置情報の取得
  4. 04OAuth認証と車両一覧の管理

活用シーン

  1. 01遠隔で空調を開始し温度を設定
  2. 02バッテリーや充電状況、位置の確認
  3. 03車両のロックや起動、充電上限の変更

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/odrobnik/tesla-fleet-api-skill --skill tesla-fleet-api

インストール後、Claude Code で/tesla-fleet-apiを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

.gitignore
.clawhubignore
SETUP.md
README.md
tesla-fleet-api
scripts/
stop_proxy.sh
command.py
start_proxy.sh
auth.py
store.py
tesla_fleet.py
tesla_oauth_local.py
vehicles.py
vehicle_data.py

詳細

Tesla Fleet API

公式 Fleet API を使用して Tesla 車両を制御します。

スクリプトの概要

スクリプト目的
command.py車両の操作(空調、充電、ロックなど)
vehicle_data.py車両データの読み取り(バッテリー、空調、位置情報など)
vehicles.py車両の一覧表示+キャッシュの更新
auth.py認証と設定
tesla_oauth_local.pyローカルコールバックサーバーを使用する OAuth ヘルパー
start_proxy.sh署名プロキシの起動(車両操作用)
stop_proxy.sh署名プロキシの停止

セットアップ/設定

セットアップ手順は SETUP.md に記載されています。

状態ディレクトリ:{workspace}/tesla-fleet-api/

  • config.json(プロバイダーの認証情報+トークン以外の設定)
  • auth.json(トークン)
  • vehicles.json(車両一覧のキャッシュ)
  • places.json(名前付きの場所)
  • proxy/(署名プロキシ用 TLS マテリアル)

.env ファイルの読み込みには対応していません。認証情報は config.json または環境変数に設定してください。


command.py - 車両の操作

Tesla を操作します。車両が 1 台のみの場合は、自動的に選択されます。

使用方法
command.py [VEHICLE] <command> [options]
  • VEHICLE - 車両名または VIN(車両が 1 台のみの場合は省略可能)
  • 車両を指定せずにコマンドを実行できます:command.py honk
  • または、車両名を指定します:command.py flash honk(車両「flash」、コマンド「honk」)

空調制御
空調の開始/停止
command.py climate start
command.py climate stop
command.py flash climate start          # specific vehicle
温度の設定
command.py climate temps <driver_temp> [passenger_temp]
command.py climate temps 21             # both seats 21°C
command.py climate temps 22 20          # driver 22°C, passenger 20°C
空調維持モード
command.py climate keeper <mode>

モード:off、keep、dog、camp


シートヒーター
command.py seat-heater --level <level> [--position <position>]
command.py seat-heater -l <level> [-p <position>]

レベル:

値名前
0off
1low
2medium
3high

位置:

値名前
0driver、front_left、fl
1passenger、front_right、fr
2rear_left、rl
3rear_left_back
4rear_center、rc
5rear_right、rr
6rear_right_back
7third_left
8third_right

使用例:

command.py seat-heater -l high                    # driver (default)
command.py seat-heater -l medium -p passenger
command.py seat-heater --level low --position rear_left
command.py seat-heater -l 2 -p 4                  # medium, rear center
command.py seat-heater -l off -p driver           # turn off

シートクーラー(送風)
command.py seat-cooler --level <level> [--position <position>]
command.py seat-cooler -l <level> [-p <position>]

レベルと位置はシートヒーターと同じです。

使用例:

command.py seat-cooler -l medium -p driver
command.py seat-cooler -l high -p passenger

シート自動空調
command.py seat-climate [--position <position>] <mode>
command.py seat-climate [-p <position>] <mode>

モード:auto、on、off

使用例:

command.py seat-climate auto                      # driver auto
command.py seat-climate -p passenger auto
command.py seat-climate -p driver off             # disable auto

ステアリングヒーター
command.py steering-heater <on|off>

使用例:

command.py steering-heater on
command.py steering-heater off

出発前空調スケジュール

出発前の空調をスケジュールするための新しい API です(非推奨の set_scheduled_departure に代わるものです)。

スケジュールの追加
command.py precondition add --time <HH:MM> [--days <days>] [--id <id>] [--one-time] [--disabled]
command.py precondition add -t <HH:MM> [-d <days>] [--id <id>]

曜日のオプション:

値説明
all毎日(デフォルト)
weekdays月曜日から金曜日
weekends土曜日と日曜日
mon,tue,wed,...特定の曜日(カンマ区切り)

曜日名:sun、mon、tue、wed、thu、fri、sat(または曜日の正式名称)

使用例:

command.py precondition add -t 08:00              # every day at 8am
command.py precondition add -t 08:00 -d weekdays  # Mon-Fri
command.py precondition add -t 07:30 -d mon,wed,fri
command.py precondition add -t 09:00 --one-time   # one-time only
command.py precondition add -t 08:30 --id 123     # modify existing schedule
command.py precondition add -t 08:00 --disabled   # create but disabled
スケジュールの削除
command.py precondition remove --id <id>

使用例:

command.py precondition remove --id 123
command.py precondition remove --id 1

充電制御
充電の開始/停止
command.py charge start
command.py charge stop
充電上限の設定
command.py charge limit <percent>

パーセントは 50~100 の範囲で指定してください。

使用例:

command.py charge limit 80
command.py charge limit 90
command.py flash charge limit 70                  # specific vehicle

ドアとセキュリティ
command.py lock                   # lock all doors
command.py unlock                 # unlock all doors
command.py honk                   # honk the horn
command.py flash                  # flash the lights
command.py wake                   # wake vehicle from sleep

車両名を指定する場合:

command.py flash wake             # wake vehicle named "flash"
command.py flash flash            # flash lights on vehicle "flash"

vehicle_data.py - 車両データの読み取り

デフォルトでは、人が読みやすい形式で車両データを取得します。

使用方法
vehicle_data.py [VEHICLE] [flags] [--json]
  • VEHICLE - 車両名または VIN(車両が 1 台のみの場合は省略可能)
  • フラグを指定しない場合は、すべてのデータを出力します
  • --json = JSON の生データを出力します
フラグ
フラグ長い形式データ
-c--chargeバッテリー残量、充電上限、充電状態
-t--climate車内/車外温度、HVAC の状態
-d--driveギア、速度、出力、方角
-l--locationGPS 座標
-s--stateロック、ドア、ウィンドウ、走行距離計、ソフトウェア
-g--guiGUI 設定(単位、24 時間表示)
--config-data車両設定(モデル、色、ホイール)
使用例
# All data
vehicle_data.py
vehicle_data.py flash

# Specific data
vehicle_data.py -c                        # charge only
vehicle_data.py -c -t                     # charge + climate
vehicle_data.py flash -c -l               # charge + location

# Raw JSON
vehicle_data.py --json
vehicle_data.py -c --json
出力例
🚗 My Tesla (online)
   VIN: 5YJ... (redacted)

⚡ Charge State
────────────────────────────────────────
  Battery:    [███████████████░░░░░] 78%
  Limit:      80%
  State:      Charging
  Power:      11 kW (16A × 234V × 3φ)
  Added:      37.2 kWh
  Remaining:  10m
  Range:      438 km (272 mi)
  Cable:      IEC

🌡️  Climate State
────────────────────────────────────────
  Inside:     11.9°C
  Outside:    6.0°C
  Set to:     20.5°C
  Climate:    Off

auth.py - 認証

OAuth トークンと設定を管理します。

使用方法
auth.py <command> [options]
コマンド
ログイン(OAuth フロー)
auth.py login

対話形式で認証 URL を生成し、コードの入力を求めて、トークンと交換します。

認証コードの交換
auth.py exchange <code>

認証コードをトークンと交換します(非対話形式)。

トークンの更新
auth.py refresh

アクセストークンを更新します。注:リフレッシュトークンはローテーションされ、新しいトークンは自動的に保存されます。

ドメインの登録
auth.py register --domain <domain>

Tesla にアプリのドメインを登録します(署名付きコマンドに必要です)。

登録後、仮想キーを登録してください:

https://tesla.com/_ak/<domain>
設定の表示
auth.py config

現在の設定を表示します(シークレットは伏せ字になります)。

設定の変更
auth.py config set [options]

オプション:

  • --client-id <id>
  • --client-secret <secret>
  • --redirect-uri <uri>
  • --audience <url>
  • --base-url <url>
  • --ca-cert <path>
  • --domain <domain>

例:

# Initial setup
auth.py config set \
  --client-id "abc123" \
  --client-secret "secret" \
  --redirect-uri "http://localhost:18080/callback"

# Configure proxy
auth.py config set \
  --base-url "https://localhost:4443" \
  --ca-cert "/path/to/tls-cert.pem"

tesla_fleet.py - 車両の一覧表示

車両を人が読みやすい形式で一覧表示します。

python3 scripts/tesla_fleet.py vehicles
python3 scripts/tesla_fleet.py vehicles --json
出力例
🚗 Name:   My Tesla
🔖 VIN:    5YJ... (redacted)
🟢 Status: Online
👤 Access: Owner

設定/プロキシ/ファイル構成

セットアップと設定の詳細はすべて SETUP.md に記載されています。


地域別ベース URL

地域オーディエンス URL
ヨーロッパhttps://fleet-api.prd.eu.vn.cloud.tesla.com
北米https://fleet-api.prd.na.vn.cloud.tesla.com
中国https://fleet-api.prd.cn.vn.cloud.tesla.cn

OAuth トークンエンドポイント(全地域共通):

https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3/token

トラブルシューティング

「vehicle unavailable: vehicle is offline or asleep」

まず車両を起動してください:

command.py wake
「command not signed」/「vehicle rejected」

署名プロキシが実行中で、正しく設定されていることを確認してください。SETUP.md の「プロキシのセットアップ」を参照してください。

トークンの有効期限切れ
auth.py refresh
複数の車両

名前または VIN で車両を指定してください:

command.py flash climate start
command.py 5YJ... honk

コマンドリファレンス全文

command.py
climate start|stop
climate temps <driver> [passenger]
climate keeper off|keep|dog|camp

seat-heater -l <level> [-p <position>]
seat-cooler -l <level> [-p <position>]
seat-climate [-p <position>] auto|on|off

steering-heater on|off

precondition add -t <HH:MM> [-d <days>] [--id <id>] [--one-time]
precondition remove --id <id>

charge start|stop
charge limit <percent>

lock
unlock
honk
flash
wake
vehicle_data.py
[VEHICLE] [-c] [-t] [-d] [-l] [-s] [-g] [--config-data] [--json]
auth.py
login
exchange <code>
refresh
register --domain <domain>
config
config set [--client-id] [--client-secret] [--redirect-uri] [--audience] [--base-url] [--ca-cert] [--domain]

コメント