teslajson
teslajson copied to clipboard
Cleanup of http connection?
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...
How are you calling the API? Why not simply delete the Connection and Vehicle objects?
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...