Tesla Wall charger (TWC3) support via vehicle-command API for Tesla vehicles
Is your feature request related to a problem? Please describe. The introduction of the Tesla vehicle-command SDK has changed the APIs for Tesla vehicle management. The TWC3 charger cannot be controled via EVCC and must be managed via changing the charging parameters on the Tesla vehicle via the SDK. The new SDK requires additional Public/Private key pairs and authority from the user for EVCC to manage the vehicle.
Describe the solution you'd like The new vehicle-command SDK is only implemented in a read-only implementation. Read-write is needed to re-indroduce the EVCC functionallity that existed with the old API. The API gateway is now region specific so additional checks are needed to use the correct gateway: You can query the users region and appropriate fleet-api URL so you should be able to dynamically assign it https://developer.tesla.com/docs/fleet-api?shell#region
Describe alternatives you've considered Other projects are also tackeling this same challenge. To date there are implementations by;
- https://chargehq.net/
- https://github.com/pkuehnel/TeslaSolarCharger
- https://www.tessie.com/
Additional context Thank you
It will be good if this is implemented to control charging, as the charging is then controlled directly on the vehicle itself. That means any charger (including mobile chargers) can work with a Tesla vehicle, very much like Charge HQ.
Couple of things:
- Make sure that https://github.com/evcc-io/evcc/pull/10802 works for you, i.e. you can retrieve soc.
- Get a Tesla developer account- follow steps at https://github.com/teslamotors/vehicle-command and note https://github.com/teslamotors/vehicle-command/issues/111
- Any insight about other self-hosted solutions is welcome. Key issue here is, that controlling the vehicle needs a private key installed on the vehicle. evcc does have a private key that can be installed but we obviously not distribute that.
- When 1+2 are completed we can look into implementation. Depends on https://github.com/teslamotors/vehicle-command/issues/29.
Hi @andig
if you need someone to test, you are welcome to get in touch. I have two evcc instances available, each with a TWC3 and a Tesla.
Problem is that in order to send vehicle commands, one must have the private key corresponding to the public key installed on the vehicle. That private key is a SECRET. One way of not distributing the secret might be running a vehicle command proxy (see https://github.com/teslamotors/vehicle-command/tree/main/cmd/tesla-http-proxy).
Not sure if thats doable- needs more investigation:
Do not listen on a network interface without adding client authentication. Unauthorized clients may be used to create excessive traffic from your IP address to Tesla's servers, which Tesla may respond to by rate limiting or blocking your connections.
...which would bring us to client certificates.
This sounds promising, the app would run the proxy or is it something EVCC needs to host?
@andig confirmed #1 is now working in US and can retrieve SOC with latest nightly. @yipikaye can you try and see if it works for you too?
@infinus yes I plan to, I'm away for a few days and for some reason it seems I can't ssh into home 😔 When is it going into the stable branch, I'll see if I can get it done before then
Problem is that in order to send vehicle commands, one must have the private key corresponding to the public key installed on the vehicle. That private key is a SECRET. One way of not distributing the secret might be running a vehicle command proxy (see https://github.com/teslamotors/vehicle-command/tree/main/cmd/tesla-http-proxy).
Not sure if thats doable- needs more investigation:
Do not listen on a network interface without adding client authentication. Unauthorized clients may be used to create excessive traffic from your IP address to Tesla's servers, which Tesla may respond to by rate limiting or blocking your connections.
...which would bring us to client certificates.
Sounds great, can't wait to test it :)
@andig May I suggest a creation of Template based on Tessie API? https://developer.tessie.com/docs/about They provide their users an API that I guess works the same way Tesla API used to work.
Thanks! ;)
@manuelmrmorgado
Tessie has private servers and can host the client secret which is needed and should not be shared. EVCC is open sourced and usually run at home so they have can’t protect those like Tessie can. They are looking at setting up a proxy but that it a work in progress. It is much easier for projects like Tessie, teslafi, or Optiwatt to introduce these changes than open source projects like EVCC or Teslamate. It’s trying to find a delicate balance between ease of use, privacy, and security.
This proxy seems promising! It's great to see the improvements and the active team. This is what open source is all about!
Feel free to open a PR for Tessi integration.
Feel free to open a PR for Tessi integration.
how much customization is needed to make it work with tessie? is it just changing the api url from the deprecated?
Hi @andig, would this issue be why I am getting [main ] ERROR 2024/02/01 19:28:58 creating vehicle ev3 failed: cannot create vehicle type 'template': cannot create vehicle type 'tesla-command': oauth2: "login_required" "Login required" "https://auth.tesla.com/error/reference/a15ecfb6-0272-46a6-b3d8-af10870b8af4-1706776138785" after switching to tesla-command and 124.0? I created the new tokens via evcc website and revoked and made them again to see if that was an issue but i get the same error and then EVCC cant control charge rate.
@haroldboom this Issue is about TWC. Please don't cross-post. Tesla integration is confirmed working. Feel free to share login information with [email protected] for further diagnosis.
@manuelmrmorgado re Tessi that would mean that the old Tesla integration would continue to work 1:1 by swapping the URL. That's an interesting idea. Since we're using https://github.com/bogosj/tesla under the hood, swapping URI and adding API key would need to be done there. I suggest to open an issue with bogosj/tesla.
...which is why this issue exists.
@haroldboom this Issue is about TWC. Please don't cross-post. Tesla integration is confirmed working. Feel free to share login information with [email protected] for further diagnosis.
I´m confused. If I understand it correct, the Tesla integration with reading values is now working again with the new API, but we cannot send any commands to the car atm, which can be done via a proxy integration?
As far as for TWC3: Didn´t the car control the whole charging in the past, since the TWC3 is not controlable? Has anything changed here?
Has anything changed here?
No and that‘s why we have this issue open. It is not about login errors!
Hi @andig is the proxy in the nightly or still in draft stage?