-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tesla Integration via official vehicle-command library #10460
Comments
Afaikt using the Tesla API requires you to run your own Domain and provide a certificate. That does not sound doable for most users. Is this perception wrong? If anyone has access and time to spend I‘d be happy to support a PR. |
It does not require Domain name nor Domain certificate unless you decided to run the included REST proxy on a public domain. The public-private key pair talked about in the README is directly used to sign (and possibly encrypt) messages similar to how PGP uses cryptography. The library even includes its own keygen tool to make key generation (and subsequent registration in your Tesla vehicle's keychain) simple.
Looks like Tesla is fully depreciating public REST servers in favor of their new protocol.
The https://github.com/teslamotors/vehicle-command directly implements this protocol
The golang library can either be used directly, via a command-line tool, or via a local REST service (which both use the library internally). Looks like all newer Tesla models will need to be switched to the new protocol. Only:
|
This comment was marked as resolved.
This comment was marked as resolved.
Its still unclear to me how this should work from user side. Where does the user obtain the token? Does he need to register a developer account? Ist aber vllt. einfach wenn wir auf Deutsch reden ;) |
Klar. Von der Nutzerseite würde das so aussehen, dass man sich ein public/private key-pair generiert und den public key direkt in der keychain des Teslas hinterlegt. Also genauso wie man das z.B. mit einem SSH public/private keypair macht. Mit dem private key kann der lokale client dann Nachrichten signieren (und in der Theorie auch verschlüsseln, dafür würde man aber normalerweise dann aus Effizienzgründen symmetrische Verschlüsslung nutzen). Der oauth token wird zusätzlich gebraucht. Das ist quasi unverändert genauso wie bis jetzt. Allerdings ist natürlich eine wichtige Frage ob in Zukunft nur noch Tesla's 3rd party tokens akzeptiert werden, die man über das Developer portal anlegt. Details dazu hier unter Setup. Ich schreibe im Anschluss mal eine Mail an fleetapisupport@tesla.com und frage nach Feedback wie die in Zukunft mit open source Projekten und inoffiziellen oauth tokens umgehen wollen. |
This comment was marked as resolved.
This comment was marked as resolved.
In der Tat muss man sich leider nun einen Partner Account registrieren, bekommt dann einen partner OAuth token, und muss dann einen generierten public key unter einer eigenen (partner) domain hosten. |
Konkrete Möglichkeit bei der jeder Nutzer unabhängig bleibt könnte wahrscheinlich wie folgt aussehen:
Soweit die Theorie. Prinzipiell auch alles automatisierbar. Aber... |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
Hi there, I tried looking around and this seems to be the most relevant issue page for the Tesla's API deprecation. One of the cloud softwares "ChargeHQ" which performs similar function as EVCC (but via third party cloud rather than self-hosting) has updated to the new Tesla system. I am wondering if this is already addressed in EVCC? Or whether it's not going to be solvable in EVCC given the requirement for hosted certificate etc (judging from the conversation above). Thanks. Link to the relevant discussion in Charge HQ: |
See #10802, this should already work (but not yet and potentially never for TWC integration). |
Gibt es einen groben Zeitrahmen, bis wann die neue API integriert sein wird? |
Das ist eine Sondersituation die wir nicht OOTB lösen können. Steuern über das neue API ist nur möglich wenn es einen private key gibt. Den können wir natürlich nicht rausgeben, d.h. jeder Anwender müsste sich selbst die entsprechenden Accounts bei Tesla besorgen und Keys erzeugen. Im Code ist das aktuell nicht berücksichtigt, könnte aber eingebaut werden. @litithio falls Du Dir selbst einen Tesla Partneraccount besorgen willst könnten wir dann zusammen schauen, wie der zu integrieren wäre. Ohne geht es nicht :/ Ergänzung: Davon unabhängig ist es mit dem PR bereits möglich, Daten vom Fahrzeug abzufragen! |
Ich hatte mir über tesla.evcc.io bereits einen Token generiert und die evcc.yaml eingetragen. Der Datenabruf war damit wie du sagst bereits möglich. Ansteuerung des Fahrzeugs leider nicht, fehlt vermutlich noch das passende Template und der damit verbundene Code. Ich bin gerne bereit mir einen Partneraccount zu besorgen und Versuchskaninchen zu spielen, falls man dafür nicht irgendwie speziellen Voraussetzungen erfüllen muss. Hast du einen Link für mich wo ich das beantragen/mich registrieren kann? |
Kenne ich gar nicht.
Siehe https://github.com/teslamotors/vehicle-command. Ist allerdings mühsam... |
|
Ich brauche dafür einen Developer Account, sehe ich das richtig? Da steht, die Registrierung muss auf ein Unternehmen erfolgen, und man muss dabei eine valide Steuernummer angeben. |
Den brauchst du... |
Ich glaube das übersteigt leider meine Möglichkeiten .... https://github.com/pkuehnel/TeslaSolarCharger/releases/tag/v2.23.0 Vielleicht lassen sich Erkenntnisse daraus ziehen, wie das auch in evcc umsetzbar wäre? |
@andig I'd be willing to create a developer account under my name/tax ID. Tesla seems to only allow unique application names. Do you want me to create one for evcc.io or do you want me to make one for a domain I control for testing purposes? It says the public key must be be placed in the /.well-known section of the application website do we have that ability with the evcc.io site? More details if needed: |
@infinus it would help to test the draft PR.
For what purpose? |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@andig ill just create one for evcc.io it is asking for the following: The whitelisted URI that the user is redirected to after they have successfully authenticated. This URI is the endpoint in your application that handles exchanging a code granted by Tesla OAuth for an access token. |
@infinus Once you figure this out (it sounds like you're close) can you share what you did in this thread? I am also willing to setup a developer account and support the effort in this thread. |
💪 @andig merged the implementation for the new API today, and we've just published nightly builds for all platforms where our Tesla integration works again. Here is what you have to do 👇 How to get Tesla Integration working?
vehicles:
- name: mytesla
type: template
- template: tesla
+ template: tesla-command
accessToken: [...] # generetad by tesla.evcc.io
refreshToken: [...] # generetad by tesla.evcc.io
...
Using local builds is still possible, but now requires a Tesla Developer account. Use the |
I updated to the nightly and made the changes above and granted cvcc all permissions. I get an error and charge control is not working. creating vehicle Infinus failed: cannot create vehicle type 'template': cannot create vehicle type 'tesla-command': cannot get vehicles: unexpected status: 421 (Misdirected Request) Vehicle not capable of charge control error on front end. |
Lets please not confuse things here. PR is finished and merged. It allows reading the Tesla again. It does NOT allow controlling it- that's entirely different story. For what is merged, no developer account is required. One thing we've not (yet) done is look at different fleet APIs. Code uses EU. Not sure what other vehicles, e.g. in Australia, would use... |
I was going to say that from my end I see no difference in the nightly vs prior ones but maybe that is because I'm based in the US so the fact that this code uses EU probably explains why! You can query the users region and appropriate fleet-api URL so you should be able to dynamically assign it, this should save you a lot of posts from non-eu users. |
Hi @andig , I can also test the Australian region. I have seen now some home automation uses open source and no developer account so maybe there are other implementations too. |
@infinus did you even configure the new integration? "Prior" it didn't even exist so that makes me suspect you're just continuing with the old config.
@yipikaye please do so. For now "can I get the soc from my Tesla". Controlling it- I repeat- is a different topic and new discussion. That said: waiting for cross-region feedback including trace log, please open new issue if not working.
What we've done sofar does NOT require a custom dev account- it is using the evcc one. |
Sure thing, I couldn't see a separate issue for TWC3 not working. Is there an existing thread we can continue this discussion or would you prefer I create a new one? I follow the not needing dev account now. But I was looking forward to fixing TWC 3. |
I created the following feature request |
Yes, I did. I generated a new access token on the site and granted all permissions and updated the evcc.yaml with the new access and refresh tokens
I was previously on 0.123.3 and updated to 0.123.9 and started getting errors in the logs like this:
I assumed this was due to the API change as the yaml had not changed between versions. I updated to nightly and made the changes and now the error says this:
I looked up up similar examples online I found that Tesla API will return misdirected request if the request is to the wrong region. If you send to the base url instead of the EU region it should reply with the correct code:
so it seems to me updating the url to https://fleet-api.prd.na.vn.cloud.tesla.com should make it compatible with all regions as using the base URL should return the region specific URL. |
When I try to generate the tokens on the new website, I always get the following error from the evcc site after I selected all permissions and clicking on allow: insufficient scopes: missing token scopes Any idea what I'm doing wrong? |
Guess I broke that, will fix today. |
Was muss ich tun, dass es wieder funktioniert? Habe bereits die beiden Token aktualisiert, leider ohne Erfolg. |
Warten. |
Worum es in diesem Issue auch gar nicht geht... geschlossen da off-topic. |
Is your feature request related to a problem? Please describe.
Tesla has announced deprecating HTTP REST APIs, which is expected to affect owners starting in 2024 and will likely break unofficial APIs and their wrappers like the currently used https://github.com/bogosj/tesla library.
Describe the solution you'd like
Reimplement Tesla Vehicle support via the official https://github.com/teslamotors/vehicle-command library.
Describe alternatives you've considered
Continue using unofficial APIs or hope they will (or make them) update to wrapping the official Tesla API.
Additional context
https://developer.tesla.com/docs/fleet-api#2023-10-02-tesla-vehicle-command-sdk
The text was updated successfully, but these errors were encountered: