Tesla Integration to Query Status and Send Commands to Your Car

The Tesla app doesn't do let you schedule either of those, so I don't think it's exposed via the API at this time. You can just turn on the HVAC with the API, which is what TeslaFi is doing.

Nothing shows up after logging in. I do NOT have MFA turned on. user and pass are 100% correct


tesla deprecated the old auth method and the new one seems very complicated.. in time maybe it will be implemented.. for now generate your token via teslafi or some other website and put it in the new token field i added . you will need to do this around every 45 days..

Authentication - Tesla JSON API (Unofficial) (timdorr.com)

see above get latest from my github

see previous post.. generate token elsewhere and put in app to use

1 Like

back to original post and rule.. this is my rule

That worked @kahn-hubitat. I used TeslaPy and captured the generated ownerapi access token in cache.json.

1 Like

for those interested i still have not got the new oauth2 working in the app. Last time i tried i locked my account out. So giving up on that for awhile.. As a workaround i found a python app to do it and got it installed on a windows box .

Here it is. now at least you can generate your tokens locally if you want. Recommend you do as I now do .. create a separate login on tesla with access to the car and use this to generate the token so if you screw up it wont lock your main account and make you reinstall the phone app etc.

GitHub - enode-engineering/tesla-oauth2: General description about how Tesla does 2FA and how to detect if a user has 2FA enabled

1 Like

this is as far as i have gotten on the new oauth2. maybe someone else can look at it .. i have gotten the url encodeing and sha256 stuff working but the first call comes back with the wrong data.

ie

trying to follow the code here in python which does work.

but first page (see login) function is not coming back correctly'

any news on this?
is there any easy way i can get the token... really missing my tesla API since i was using it to preheat by a schedule, as well as opening the charge port...

easisest is to pay the 30 bucks a year or whatever from teslafi and get the token from there. or if you are cheap install the python stuff i bookmarked above and generate your own token.

1 Like

hm... i am not interested in doing any of those... so i will have to wait to someone fixes the app/driver... :slight_smile:

dont hold your breath.. i dont think it is going to happen.. i kinda figured out why it is not working and why the python requires the chromedriver installed.. the new first login page returns a page that requires a javascript redirection and functions to display and decode the actual page .. This currently is impossible in hubitat. That is whay the page was coming back as a success with code 200 but did not display the correct response/info and has a message that javascript needs to be enabled.

omg... so behaps a solution would be to have a webserver doing the login and returning the token... and then create an http request in the hubitat app/driver for that

This would of cause be an own or thrusted script, otherwise it would just float around with everyone gaining access to ones Tesla

on another note, the tesla app for my smartwatch is broken as well..

perhaps i will look into making such a webserivce based on tesla-api.timdorr.com (create an external php script for doing this login return token) but i dont have a lot of time on my hands :frowning:

i have zero experience with groovy, but i have forked some drivers :slight_smile:

lots of API calls made with WebCore, but that wouldnt be as user friendly.

i have done that for myself.. i really dont want to expose a web server. but i have a scheduled python job locally that runs the code to generate a cookie and pushes it to a local webserver that i query. if you check the lastest code there is a new field where you can enter a web address to get the cookie.. it expects the cooke to be in the format generated by the python code,'

ie

I know it works initially but my cookie hasnt expired yet so dont know if it will work correctly on expiration..

if someone else wants to host the python code with a web page to refresh the cooke and return the response as follows i can help, but i dont really want to host a front facing website.

nice... well do you have the python code i could "borrow" i will just put an Raspberry Pi up for the job then...

i figure i just have to get the latest app / driver from this thread to support the URL call?

the code is posted above in this thread.. see this.. if you have trouble getting it working i can help.. it would be pretty easy to link it to a web page

i left the email and password in the driver code, in case we ever do get it working internally in the future.

this is my command prompt script to generate the cookie.. intererstingly it would not run as a windows scheduled job with task scheduler.. it had to get a 3rd party scheduler to get it to run correctly.

1 Like

what is this for in the app setup?

ya i should add a better explanation. it is a notification device to send a couple of new notifications when the cookie update is attempted and if it suceeds or fails.

I just added the description and updated the git hub.

also if someone wants to host this.. in terms of a tesla it is not a security concern as the script can take the username password generate the token returned in a page, and never store any values on the server.. The security issue is just having a widely used front facing site that peeps can try to hack into..