Tesla API Access


#84

Odd… TeslaFi says I’ve already got a V3 token, but WebCoRE seems to not work when trying to wake up the car. TeslaFi definitely has full access. Up until a half a week ago, everything was working fine with the same token. Literally nothing has changed in the code. Here’s an example of your wake-up… with the rest disabled. And yes, the car is awake already prior to the test.

Screenshot%202021-02-02%20121402

Screenshot%202021-02-02%20121511


#85

That’s not unexpected at this point. Unfortunately, I’m deep in other projects and it may take me a week or two work through this.


#86

So I’ve been doing some experimenting and this is what I’ve done to get everything working for me. It seems to be the wake-up loop that got the errors for some reason now, so I modified/removed it. And yes… I turned all the variables to global.

The way my " TESLA Warm car at work at end of day" piston works is…

  • check if the car is ASLEEP. > If yes… wake it (wait 60sec… probably 45 or 30 is also actually good)
  • if “ASLEEP” wasn’t a match then check if ONLINE
  • If not ONLINE then car can’t be reached so just exit piston
  • if all worked out, then rest of piston will run
  • so…
  • check if at work
  • If yes then start climate
  • wait 40min then check if STILL at work
  • If yes turn off climate as there’s a departure delay
  • if no… exit piston since I’m now driving


#87

Has anyone got setting temperatures to work? Since day one for me (since Nov), it has never worked. When the command is sent to the car, the cars’ climate automatically goes to “LO” and the (I’m assuming) AC comes on instead of the car being set to 24C.

Here is my test piston which I manually run via the TEST button.
And yes… the car is already awake.


#88

Thanks for putting this together for the community! Any update on the status of an updated piston? My token has expired, and I’m not able to figure out how to get a new one. Thanks again!


#89

I have made some preliminary efforts. While generating the refresh token appears to be outside the scope of webCoRE’s capabilities, I believe webCoRE will be able to refresh the access token as needed and that piston functionality can be restored with some modifications. However, I haven’t gotten that far yet.

As for the refresh token, I was able to generate one using a Python script. There is also an iOS app called Authla that reportedly can be used to generate a token, but I haven’t tried it.

I’ll be tinkering with this further in the coming days as time allows.


#90

Since I also use TeslaFi, I’ve been relying on its auto-generated token to copy/paste it into WebCoRE. I find if I use these WebCoRE routines for token generation, it becomes a conflict with the TeslaFi token and is null since a new token was generated via WebCoRE. It would be great if there was a way to just automatically take the TeslaFi token and use here in WebCoRE.


#91

Thank you!.. I use TeslaFi as well, so I’ve resorted to that for now and paused the refresh piston.


#92

Great, thanks! I’ll keep an eye out for an update. In the meantime I’ll use the manual method noted by @PrometheusXex below.


#93

Like I said before, unless of course it was working out for you, but when WebCoRE would do the refresh, it would kill the TeslFi token (and vice versa). They compete… not work with each other. So even though this issue is resolved with WebCoRE, it’s still a pain… at least it was for me.


#94

I thought I had documented this potential conflict, but reading back it’s apparent I didn’t do so within this thread. To the best of my knowledge, you’re right that you cannot have webCoRE and TeslaFi both generating and/or refreshing the access tokens independently.

Sharing the token or allowing an account to have more than one token are both good solutions, but a bit beyond the purpose of these pistons, which was to demonstrate how webCoRE could be used to access the API. However, with webCoRE and ST parting ways before the end of the year due to the demise of the groovy platform, I’ll probably be focusing my efforts elsewhere unless I decide to move to Hubitat.