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

Only poll Tesla API when charging is active #96

Open
glynhudson opened this issue Jun 26, 2020 · 7 comments
Open

Only poll Tesla API when charging is active #96

glynhudson opened this issue Jun 26, 2020 · 7 comments
Assignees
Labels
bug Something isn't working tesla Issues related to the Tesla integration

Comments

@glynhudson
Copy link
Collaborator

After enabling the OpenEVSE Tesla integration I noticed a higher than average vampire drain (12 miles lost overnight) on a 2015 Model S. I setup TeslaMate which logs the state of the vehicle, as well as lots of useful info.

TeslaMate confirmed my suspicion that the car was not going to sleep. After the OpenEVSE Tesla integration was switched off at about 13:00 shortly after the car went to sleep.

Screenshot from 2020-06-26 21-22-04

@chris1howell @lincomatic can you replicate this experience? Have you noticed higher than usual vampire drain if using the OpenEVSE Tesla API? Do you have any other integrations running using the Tesla API? If so these could also be keeping the car awake. What is the usual vampire drain on your cars?

I'll continue to monitor and test this.

@glynhudson glynhudson added the bug Something isn't working label Jun 26, 2020
@chris1howell
Copy link
Member

chris1howell commented Jun 26, 2020 via email

@lincomatic
Copy link
Member

@glynhudson sorry, i don't have a Tesla, so I can't do much testing. I developed the API code using Chris' account

@mikeh2010
Copy link

mikeh2010 commented Jun 27, 2020

It polls the Tesla API by calling /api/1/vehicles/#{id}/vehicle_data regularly. Wouldn't it be better to use the streaming websocket API instead?

Tesla doesn’t care for their servers being polled repeatably so a streaming websocket API solution might be better?

Advantages would be:

  • Instantaneous updates of car data (around once per second) - no polling delays
  • No waking up in case the car is sleeping (not 100% sure about this though - but it seems to be the case in my tests)
  • More future-proof, since the Tesla app also seems to be abandoning the polling method

Some code samples:
https://github.com/timdorr/tesla-api/blob/master/lib/tesla_api/stream.rb
https://github.com/mseminatore/TeslaJS/pull/158/files#diff-8cc7128b6d8cb9a5b8a5fbdc3dd86338

edit/ Also Teslamate uses this idea...

@glynhudson
Copy link
Collaborator Author

Polling the Tesla API will keep the car awake and prevent it from sleeping.

I've added a note to the docs to mention the increased vampire drain if using the integration.

This doesn't seem optimal, loosing approx 12 miles/day. That's a lot of energy over a year! Also increased wear on the MCU and DC-DC converter since it's running pretty much continuously. Only polling when charging/driving and less regularly sounds sensible.

@glynhudson sorry, i don't have a Tesla, so I can't do much testing. I developed the API code using Chris' account

Nor do I, I borrowed one from a family member for testing

Wouldn't it be better to use the streaming websocket API instead?

That sound like a good solution. Would you be able to put together a pull-request for this if you're familiar with the API?

@chris1howell
Copy link
Member

chris1howell commented Jun 29, 2020 via email

@mikeh2010
Copy link

Ok

@glynhudson
Copy link
Collaborator Author

e.g If evse_state == 3 then do Tesla loop

@glynhudson glynhudson changed the title Tesla Integration keeping car awake? Only poll Tesla API when charging is active Jul 16, 2020
@jeremypoulter jeremypoulter added the tesla Issues related to the Tesla integration label Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tesla Issues related to the Tesla integration
Projects
Development

No branches or pull requests

5 participants