Skip to content
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

Cleanup of http connection? #29

Open
tillhanke opened this issue Apr 11, 2021 · 2 comments
Open

Cleanup of http connection? #29

tillhanke opened this issue Apr 11, 2021 · 2 comments

Comments

@tillhanke
Copy link

Is there a way to close the http connections when the requests and posts are done?

Our vehicle seems to be awake all the time an I have the suspicion that it is because the API is connected all the time...

@gglockner
Copy link
Owner

gglockner commented Apr 11, 2021

How are you calling the API? Why not simply delete the Connection and Vehicle objects?

@tillhanke
Copy link
Author

I am calling the API as explained in the README

c = teslajson.Connection('youremail', 'yourpassword')
v = c.vehicles[0]
v.wake_up()

Because I didn't see a method for closing the session in your code I searched for the OAuth docs and found the part about requests there its explained, that one should always close the sessions with the close method.

Developers SHOULD close a Requests Session when the jobs are done. You can call .close() manually, or use a with context to automatically close the session:

Maybe its a option to just add a method that closes the session within the Connection Class? I fixed my problem by directly calling c.session.close() this way the Tesla didn't seem awake for so long anymore.
Sadly there is no gotosleep command within the teslajson api...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants