ngardiner / TWCManager

Control power delivered by a Tesla Wall Charger using two wires screwed into its RS-485 terminals.
The Unlicense
130 stars 55 forks source link

Actual status of the new Tesla API integration - for noobs #563

Open danielsan1 opened 6 months ago

danielsan1 commented 6 months ago

Hi all,

Again, many thanks for your efforts on the TWCM project!

I really tried to follow the development activities here but it reads quite complex and I’m still not sure what to do with the new Tesla API now.

Can you please help with a short (beginner-friendly :) update if/how we can use the new Tesla API with TWCM 1.3.1? Or can/would you recommend a not-so-difficult workaround? Or would an upgrade to the developer version 1.3.2 help?

Thank you very much in advance!

Daniel

Flitzer42 commented 6 months ago

Hi @danielsan1 , I have the same issues as you already wrote in October. Installing 1.3.1 on a raspberry with the latest OS (bullseye) fails. Installing on a raspberry with buster (legacy, comes with Python 3.7) works partially. With this, I can at least enter the credential and start / stop charging works fine. But as soon as the the token expires, it stops working. The refresh does not work. When TWCManager attempts to refresh, the refresh token gets deleted from the settings.json. I really hope that @MikeBishop or @ngardiner will find a solution. I also failed to run the docker image. BTW: I am using OpenWB in parallel and they managed to get it running with the new API. Klaus

MikeBishop commented 6 months ago

That PR was merged on 1/23, so after 1.3.1. Until a new release is cut, you'd need to be on the dev branch to use the new API. However, the tokens I'm currently using are from the legacy API and continuing to work. If you're using the dev branch and still failing with legacy tokens, that's worth investigating. Hopefully @ngardiner will cut a release soon to include those changes.

Getting tokens for the new API is a bit involved; my attempt at making it as user-friendly as possible is here, if/when it turns out we all need to go that route. Given that Tesla hasn't fully disabled the legacy API yet, I'm hoping they have a selfhost user plan that's better than that.

alexeiw123 commented 6 months ago

That PR was merged on 1/23, so after 1.3.1. Until a new release is cut, you'd need to be on the dev branch to use the new API. However, the tokens I'm currently using are from the legacy API and continuing to work. If you're using the dev branch and still failing with legacy tokens, that's worth investigating. Hopefully @ngardiner will cut a release soon to include those changes.

Getting tokens for the new API is a bit involved; my attempt at making it as user-friendly as possible is here, if/when it turns out we all need to go that route. Given that Tesla hasn't fully disabled the legacy API yet, I'm hoping they have a selfhost user plan that's better than that.

I'm also having trouble with the legacy API tokens on the dev branch. Sometimes I can get my API and refresh token to 'stick' but it doesn't seem to last. I've changed my configuration to stop responding to slaves and use twc control only for the time being. Interesting to me is that my teslamate connection with legacy API is still humming along just fine.

I see there is a way to leverage teslamate tokens from TWC manager (https://github.com/ngardiner/TWCManager/blob/main/docs/modules/Vehicle_TeslaMate.md) but I've not been able to figure my way through this, given my teslamate is running in a docker and I full flat when the instructions stop!

Also in recent weeks after updating dev branch, my TWC install host has become non responsive occasionally. webpage goes down, no MQTT updates and can't SSH to host. I have to power cycle it to come back. I've done a git pull this morning in the hope that some change has resolved that issue, whether or not it's related, I'm unsure.

ngardiner commented 6 months ago

I see there is a way to leverage teslamate tokens from TWC manager (https://github.com/ngardiner/TWCManager/blob/main/docs/modules/Vehicle_TeslaMate.md) but I've not been able to figure my way through this, given my teslamate is running in a docker and I full flat when the instructions stop!

Sadly this functionality broke when symmetric encryption was added to TeslaMate to stop people from doing exactly what we were doing.

I haven't removed it because it is entirely possible for us to decrypt the tokens with the encryption key supplied to TM, the problem is time as the encryption approach isn't documented anywhere except the code itself, so it requires reading through the elixir code to work out how it is implemented and to reverse it.

alexeiw123 commented 6 months ago

I see there is a way to leverage teslamate tokens from TWC manager (https://github.com/ngardiner/TWCManager/blob/main/docs/modules/Vehicle_TeslaMate.md) but I've not been able to figure my way through this, given my teslamate is running in a docker and I full flat when the instructions stop!

Sadly this functionality broke when symmetric encryption was added to TeslaMate to stop people from doing exactly what we were doing.

I haven't removed it because it is entirely possible for us to decrypt the tokens with the encryption key supplied to TM, the problem is time as the encryption approach isn't documented anywhere except the code itself, so it requires reading through the elixir code to work out how it is implemented and to reverse it.

Ah, well I'm glad I didn't invest too much time in this. Could it be worth an issue/PR over on the teslamate git now that there's a new development team, to see if teslamate could add support for third party apps to leverage it's connection to the tesla API?

ngardiner commented 6 months ago

I've been watching this discussion here: https://github.com/teslamate-org/teslamate/discussions/3379 Honestly, having read the code just now it seems trivial, but I was hoping someone else would get to it before me. I'll have a go at it tonight.

alexeiw123 commented 6 months ago

I've been watching this discussion here: teslamate-org/teslamate#3379 Honestly, having read the code just now it seems trivial, but I was hoping someone else would get to it before me. I'll have a go at it tonight.

That's great. If you have luck in that I'd be happy to help you build instructions for a docker install of teslamate. I have no idea how to access the files within the teslamate install inside a container/volume so it would need to be a fairly guided walkthrough.

danielsan1 commented 6 months ago

Thank you for the clarification @MikeBishop I will try checkout main. And I'll keep my fingers crossed that they will come up with a better selfhost user solution... but will start reading your guide anyway 👍 Thanks

alexeiw123 commented 5 months ago

Would love a noobs instruction for where to configure the fleet API. I've got the public key hosted using my domain I just don't know how to configure TWCManager to point to it. I can't get the old API to work anymore.