bogosj / tesla

Provides a wrapper around the API to easily query and command a Telsa car.
Other
23 stars 18 forks source link

initial implementation for Powerwall control #110

Closed GrimmiMeloni closed 12 months ago

GrimmiMeloni commented 1 year ago

This adds a minimal implementation of the Products API, used to read Tesla Energy products data. Also, adds support for a single command against Tesla Energy Sites, allowing to control the battery reserve percentage which is usually controlled via the Tesla App.

I did not add support for the entirety of the returned JSON structures, as it is rather big and contains a lot of (uninteresting?) stuff. Also, it is not clear, how Tesla slices the data. A lot of the information specific to e.g. a Powerwall is also returned partial when just listing the products. Either way, there's room for improvements or extensions if a specific field is missing.

Caveat: I do not own a Tesla car, so I do not know if and how the products endpoint responds if you have both a car and energy products. I tried to make the implementation pretty generic, by only requiring idand resource_type in the JSON replies. I use the presence of energy_site_id as an indicator that the given product is an energy site (and not a car).

The included example shows how to use the implemented calls to both read information for the energy site and optionally also allows to change the battery reserve percentage.

andig commented 1 year ago

LGTM. I'm not a big fan of embedding the client in the result, but that's what we're already doing.

GrimmiMeloni commented 12 months ago

Can we merge this @bogosj ?

bogosj commented 12 months ago

Released as v1.2.0. Thanks!