lephisto / tesla-apiscraper

API Scraper for pulling Vehicle Statistics from the Tesla Owner API into an InfluxDB + Grafana Dashboards
GNU Lesser General Public License v3.0
364 stars 102 forks source link

Calling Tesla API every second while driving seems excessive? #64

Open galmok opened 5 years ago

galmok commented 5 years ago

I just did a test drive monitored by this piece of software, and it does work. Great!

But I can't help thinking this software putting some load on the servers and transmission to the car that isn't quite necessary. I mean, while driving, the car is polled every second. I believe data quality wont suffer much if slower polling is used.

Also, I notice that the polling wanders from 1 to 2048 (1,2,4,8, ..., 1024, 2048) seconds after the car is stopped, and from 2048 to 1 (also, 2048, 1024, 512, ..., 4, 2, 1) when the trip starts. Couldn't this be optimized a bit when the Android app is being used? The app should stop and start the scraping, but according to my little test, it does seemingly nothing.

Is there any way to see if the android app actually works? To see if it detects the cars bluetooth...

Anyway, the major part of the software works just great, I just feel it is so close to perfect that it should have this last push. :)

eliluong commented 5 years ago

To see if API is working, you have to use something that can send a HTTP POST request with the correct headers and then the scrape command in the request body. You will see the result in the console window. And if it works, then the poll interval should be reset to 0, and subsequently double starting from 1, and once it detects drive/reverse state, it will start polling every 1 second, which I think can be changed in the code where it says if shift == "R" or shift == "D":

I think I had to add disableScrape = False and car_active_state = "scrape request" to the section of code that says logger.info("Resume Scrape requested") in order to make it work. I'm not sure if any other adjustments need to be made.