Skip to content

Latest commit

 

History

History
135 lines (95 loc) · 2.32 KB

File metadata and controls

135 lines (95 loc) · 2.32 KB

CLI Guide

这份文档说明 tesla 命令的主要用法。

命令分组

基础查询

  • tesla cars
  • tesla car <id>
  • tesla drives <car-id>
  • tesla charges <car-id>
  • tesla battery <car-id>
  • tesla efficiency <car-id>
  • tesla mileage <car-id>
  • tesla projected-range <car-id>
  • tesla tpms <car-id>

历史与位置

  • tesla states <car-id>
  • tesla updates <car-id>
  • tesla locations <car-id>
  • tesla visited <car-id>
  • tesla timeline <car-id>
  • tesla where <car-id>
  • tesla vampire <car-id>

统计与详情

  • tesla stats charging <car-id>
  • tesla stats driving <car-id>
  • tesla stats period <car-id>
  • tesla detail drive <record-id>
  • tesla detail charge <record-id>

工具类命令

  • tesla query <json>
  • tesla screenshot ...
  • tesla mqtt ...
  • tesla config ...
  • tesla notify ...
  • tesla nav ...

常用示例

查看车辆列表

tesla cars -o json

查看最近 5 条行程

tesla drives 1 -l 5

查看最近 30 天充电记录

tesla charges 1 --from now-30d --to now

截取某一天的日报/行程图

tesla screenshot daily 2026-03-06

截取任意时间范围的行程图

tesla screenshot range --from "2026-02-21 10:00" --to "2026-02-22 04:00" -c 1

查看电池健康

tesla battery 1 -o json

查看当前位置

tesla where 1 -o json

带高德逆地理信息:

tesla where 1 --amap

使用统一 JSON 协议查询

tesla query '{"version":"1.0","type":"drives","carId":1,"timeRange":{"semantic":"last_7_days"}}'

这是最稳定的程序化入口,CLI 子命令、OpenClaw 的自然语言调用、以及自动化场景都应该尽量收敛到这套协议。

输出格式

大部分命令支持:

  • -o table
  • -o json

默认通常是 table,如果要做脚本集成,建议直接使用 json

时间范围

很多命令支持:

  • --from
  • --to

常见值:

  • now
  • now-7d
  • now-30d
  • now-1y

代码阅读建议

如果需要修改 CLI,推荐按这个顺序看:

  1. src/cli/index.ts
  2. src/cli/commands/*
  3. src/core/query-executor.ts
  4. 对应的 src/core/services/*

深入参考

字段定义、查询类型和协议细节见: