网淘吧来吧,欢迎您!

Tesla Fleet Api技能使用说明

2026-03-29 新闻来源:网淘吧 围观:23
电脑广告
手机广告

特斯拉车队API

通过官方车队API控制特斯拉车辆。

脚本概述

脚本用途
command.py车辆指令(气候控制、充电、车锁等)
vehicle_data.py读取车辆数据(电池、气候、位置等)
vehicles.py列出车辆 + 刷新缓存
auth.py认证与配置
tesla_oauth_local.py带有本地回调服务器的OAuth辅助工具
start_proxy.sh启动签名代理服务器(用于车辆指令)
stop_proxy.sh停止签名代理服务器

设置 / 配置

设置文档位于SETUP.md文件中。

Tesla Fleet Api

状态目录:{workspace}/tesla-fleet-api/

  • config.json(供应商凭证 + 非令牌配置)
  • auth.json(令牌)
  • vehicles.json(缓存的车辆列表)
  • places.json(命名位置)
  • proxy/(用于签名代理的TLS材料)

.env文件加载 — 凭证位于config.json或环境变量中。


command.py - 车辆命令

对您的特斯拉执行命令。如果只有一辆车,车辆会自动被选中。

用法

command.py [VEHICLE] <command> [options]
  • 车辆- 车辆名称或VIN(如果只有一辆车,此项可选)
  • 可以在不指定车辆的情况下运行命令: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>

模式:关闭保持宠物模式露营模式


座椅加热

command.py seat-heater --level <level> [--position <position>]
command.py seat-heater -l <level> [-p <position>]

级别:

数值名称
0关闭
1
2
3

位置:

名称
0驾驶员,前排左侧,前排左
1乘客,前排右侧,前排右
2后排左侧,后排左
3后排左侧后方
4后排中间,后排中
5后排右侧,右后
6后右后座
7第三排左侧
8第三排右侧

示例:

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>

模式:自动,开启,关闭

示例:

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>]

日期选项:

描述
全部每天(默认)
工作日周一至周五
周末周六和周日
周一,周二,周三,...特定日期(以逗号分隔)

日期名称:周日周一周二周三周四周五周六(或完整名称)

示例:

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]
  • 车辆- 车辆名称或VIN(如果只有一辆车则为可选)
  • 无标志 = 所有数据
  • --json= 原始JSON输出

标志

标志长格式数据
-c--charge电池电量、充电限制、充电状态
-t--climate车内/车外温度、暖通空调状态
-d--drive档位、速度、功率、航向
-l--locationGPS坐标
-s--state锁、车门、车窗、里程表、软件
-g--gui图形用户界面设置(单位、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>

向特斯拉注册您的应用域名(用于签名命令所必需)。

注册后,请登记您的虚拟钥匙:

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

故障排除

"车辆不可用:车辆离线或处于休眠状态"

请先唤醒车辆:

command.py wake

"命令未签名" / "车辆已拒绝"

请确保签名代理正在运行且配置正确。请参阅SETUP.md§ 代理设置

令牌已过期

auth.py refresh

多辆车

通过名称或车辆识别码指定车辆:

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]

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏
文章底部电脑广告
手机广告位-内容正文底部

相关文章

您是本站第326370名访客 今日有221篇新文章/评论