teslatte/README.md

117 lines
4.1 KiB
Markdown
Raw Normal View History

2023-10-10 12:54:03 +11:00
# Teslatte 🚗🔋☀️☕
2022-07-21 13:46:49 +10:00
2023-09-20 13:53:19 +10:00
<a href="https://crates.io/crates/teslatte">![Crates.io](https://img.shields.io/crates/v/teslatte?style=for-the-badge&color=c02020)</a>
<a href="https://docs.rs/teslatte">![docs.rs](https://img.shields.io/docsrs/teslatte?style=for-the-badge)</a>
<a href="https://github.com/gak/teslatte#license">![MIT or Apache-2.0](https://img.shields.io/crates/l/teslatte?style=for-the-badge)</a>
2022-07-21 13:59:31 +10:00
> #### ⚠️ 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.
2023-09-20 13:56:36 +10:00
>
2023-10-22 10:45:55 +11:00
> `0.1.x` will have breaking API changes. Don't rely on this project for anything important yet.
2023-10-22 09:41:02 +11:00
>
> Using Rust nightly until `async_fn_in_trait` is stable.
2022-07-21 13:46:49 +10:00
2023-08-30 20:19:50 +10:00
Teslatte is both a CLI and a Rust crate for interacting with the Tesla API.
2022-07-21 13:46:49 +10:00
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.
2023-08-30 20:19:50 +10:00
## APIs implemented
2022-07-21 13:46:49 +10:00
Only the Owner API is partially supported by this crate, with plans to support the Fleet API and the Command Mode SDK.
[`API.md`](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.
2022-07-21 13:46:49 +10:00
2023-10-20 12:00:06 +11:00
## References
2022-07-21 14:00:53 +10:00
Thanks to https://tesla-api.timdorr.com/ for their excellent reference.
2022-07-21 13:59:31 +10:00
Tesla recently released [API documentation for their "Fleet API"](https://developer.tesla.com/docs/fleet-api) which appears to be similar to the Tesla Owner API.
Tesla also recently released a [Command Mode SDK](https://github.com/teslamotors/vehicle-command/) which also includes a proxy for the Fleet API.
2023-10-20 12:00:06 +11:00
2023-08-29 14:02:46 +10:00
## CLI
There is a CLI that can be used to interact with the API. Example:
```bash
$ 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:
2023-08-30 20:19:50 +10:00
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)
2023-08-29 14:02:46 +10:00
Arguments:
<ID>
Options:
-h, --help Print help
2023-08-30 20:19:50 +10:00
$ teslatte api vehicle 1234567890 vehicle_data
2023-08-29 14:02:46 +10:00
{ ... }
2022-07-21 13:46:49 +10:00
2023-08-29 14:02:46 +10:00
```
2022-07-21 13:46:49 +10:00
2023-08-30 20:19:50 +10:00
## Crate example
2022-07-21 13:46:49 +10:00
2023-08-29 14:02:46 +10:00
A basic example: [examples/basic.rs](examples/basic.rs)
2022-07-21 13:46:49 +10:00
## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
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
2023-10-10 12:54:03 +11:00
dual licensed as above, without any additional terms or conditions.