Go to file
2023-12-28 13:06:34 +11:00
.github ci: daily deps check 2023-11-03 09:32:10 +10:00
examples change!: vehicle_data now accepts a struct instead of VehicleId 2023-11-11 11:07:24 +11:00
src my changes 2023-12-28 13:06:34 +11:00
tesla_api_coverage docs: README and API updates about APIs 2023-10-25 15:49:57 +11:00
testdata fix: vehicle api changes as of "api_version 67" 2023-11-11 09:38:44 +11:00
.gitignore chore: gitignore .idea 2023-08-29 14:05:52 +10:00
API.md docs: README and API updates about APIs 2023-10-25 15:49:57 +11:00
Cargo.toml chore(deps): update rustls requirement from 0.21.7 to 0.22.1 2023-12-11 08:28:45 +00:00
CHANGELOG.md chore(changelog): 0.1.11 2023-11-11 11:26:56 +11:00
justfile chore: cargo audit in justfile 2023-10-20 08:11:23 +11:00
LICENSE-APACHE fix: Add licences 2022-07-21 13:55:45 +10:00
LICENSE-MIT fix: Add licences 2022-07-21 13:55:45 +10:00
README.md docs(readme): add build status badge 2023-11-03 10:26:58 +11:00
rust-toolchain.toml chore: nightly notes and rust-toolchain 2023-10-22 10:45:03 +11:00

Teslatte 🚗🔋☀️

Crates.io docs.rs GitHub Workflow Status MIT or Apache-2.0

⚠️ Alpha Warning! ⚠️

This Rust crate is still in alpha stage. It is something I quickly put together if anyone needed it. I'm aiming to work on it as I need more features.

0.1.x will have breaking API changes. Don't rely on this project for anything important yet.

Using Rust nightly until async_fn_in_trait is stable.

Teslatte is both a CLI and a Rust crate for interacting with the Tesla API.

It is fairly trivial to add in new endpoints if you feel like creating a PR, but please:

  • Write some unit tests if it relies on new or changed data structures.
  • Let me know if your PR is a massive change before spending a lot of time on it.

APIs implemented

Only the Owner API is partially supported by this crate, with plans to support the Fleet API and the Command Mode SDK.

API.md contains a table of all known Tesla APIs (official and unofficial) and if Teslatte supports it, and where the API details were scraped from.

References

Thanks to https://tesla-api.timdorr.com/ for their excellent reference.

Tesla recently released API documentation for their "Fleet API" which appears to be similar to the Tesla Owner API.

Tesla also recently released a Command Mode SDK which also includes a proxy for the Fleet API.

CLI

There is a CLI that can be used to interact with the API. Example:

$ teslatte --help
Usage: teslatte api [OPTIONS] <COMMAND>

Commands:
  vehicles      List of vehicles
  vehicle       Specific Vehicle
  energy-sites  List of energy sites
  energy-site   Specific energy site
  powerwall     Powerwall queries
  help          Print this message or the help of the given subcommand(s)

Options:
  -a, --access-token <ACCESS_TOKEN>  Access token. If not provided, will try to load from the cli.json file [env: TESLA_ACCESS_TOKEN=]
  -h, --help                         Print help
  
# Prints a URL to start the OAuth flow, then asks for the token URL, then saves the token to `cli.json`.
$ teslatte auth --save 

# Lists your vehicles:
$ teslatte api vehicles
{
  "response": [{
    "vehicle_id": 1234567890,
  }]
}

$ teslatte api vehicle 1234567890
Specific Vehicle

Usage: teslatte api vehicle <ID> <COMMAND>

Commands:
  vehicle-data             Get vehicle data
  charge-port-door-open    Open the charge port door or unlocks the cable
  charge-port-door-close   For vehicles with a motorized charge port, this closes it
  set-charge-limit         Set charge limit
  set-charging-amps        Set charge amps
  charge-standard          Set the charge limit to the standard %
  charge-max-range         Set the charge limit to the maximum %
  charge-start             Start charging
  charge-stop              Stop charging
  set-scheduled-charging   Set scheduled charging
  set-scheduled-departure  Set scheduled departure
  honk-horn                Honk!
  flash-lights             Flash the lights
  help                     Print this message or the help of the given subcommand(s)

Arguments:
  <ID>

Options:
  -h, --help  Print help
  
$ teslatte api vehicle 1234567890 vehicle_data
{ ... }

Crate example

A basic example: examples/basic.rs

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.