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
365 stars 104 forks source link

No sleep at all since start of scapping ? is there anything to setup ? #52

Open potens1 opened 5 years ago

potens1 commented 5 years ago

Hi, Thank you for the nice personal scrapper you write !

I've something that I should have missed, how to let the car sleep ? The car is parked for more than 17h, but it sis not has gone to sleep and the battery is going low pretty fast (for not doing anything)(up to 1% per hour, but more often 1% per 2 hours)

The logs show always the same loop:

2019-05-19 09:11:21 DEBUG    Car State: online Poll Interval: 1
2019-05-19 09:11:21 DEBUG    >> Request vehicle data
2019-05-19 09:11:22 DEBUG    Only minimal range difference received. No change registered to avoid wakelock.
2019-05-19 09:11:22 DEBUG    Value Change, SG: charge_state: Logging...charger_voltage: old value: 0, new value: 2
2019-05-19 09:11:22 DEBUG    VALIDITY CHECK VIOLATED >>> charger_voltage:new_value < 10
2019-05-19 09:11:22 DEBUG    Only minimal range difference received. No change registered to avoid wakelock.
2019-05-19 09:11:22 DEBUG    Only minimal range difference received. No change registered to avoid wakelock.
2019-05-19 09:11:22 INFO     Writing Points to Influx: charge_state
2019-05-19 09:11:22 DEBUG    Only minimal temperature difference received. No change registered to avoid wakelock.
2019-05-19 09:11:22 DEBUG    Only minimal temperature difference received. No change registered to avoid wakelock.
2019-05-19 09:11:22 DEBUG    starting thread elevator:XX.XXXXXXX/XX.XXXXXX/1558257082818
2019-05-19 09:11:22 INFO     Asleep since: 0 Sleeping for 1 seconds..
2019-05-19 09:11:23 DEBUG    Elevation: 171
2019-05-19 09:11:23 DEBUG    Car State: online Poll Interval: 1
2019-05-19 09:11:23 DEBUG    >> Request vehicle data
2019-05-19 09:11:25 DEBUG    Only minimal range difference received. No change registered to avoid wakelock.
2019-05-19 09:11:25 DEBUG    Value Change, SG: charge_state: Logging...charger_voltage: old value: 0, new value: 2
2019-05-19 09:11:25 DEBUG    VALIDITY CHECK VIOLATED >>> charger_voltage:new_value < 10
2019-05-19 09:11:25 DEBUG    Only minimal range difference received. No change registered to avoid wakelock.
2019-05-19 09:11:25 DEBUG    Only minimal range difference received. No change registered to avoid wakelock.
2019-05-19 09:11:25 INFO     Writing Points to Influx: charge_state
2019-05-19 09:11:25 DEBUG    Only minimal temperature difference received. No change registered to avoid wakelock.
2019-05-19 09:11:25 DEBUG    Only minimal temperature difference received. No change registered to avoid wakelock.
2019-05-19 09:11:25 DEBUG    starting thread elevator: starting thread elevator:XX.XXXXXXX/XX.XXXXXX/1558257084875
2019-05-19 09:11:25 INFO     Asleep since: 0 Sleeping for 1 seconds..
2019-05-19 09:11:25 DEBUG    Elevation: 171

The version running is 2019.5

Any advice ? Thank you

olexs commented 5 years ago

I had the same issue after installing. Merging https://github.com/lephisto/tesla-apiscraper/pull/48 into my local code has helped - for some reason it's not yet merged into master. Very rarely my car still remains awake for longer periods of time, but mostly it goes into sleep as it should.

lephisto commented 5 years ago

Will be merged when I get time to review it. Few days from now...

potens1 commented 5 years ago

Great ! Thank you.

CptanPanic commented 5 years ago

Yes merging #48 does now allow me to sleep. But now I don't get any data while it is asleep, which I guess is expected. Maybe we can configure to allow to wake up every once in a while to get some data?

potens1 commented 5 years ago

@CptanPanic Maybe I miss the point, but what's the use case of having data for a sleeping car ? (real question since I did not use the apiscraper a lot yet). Thx

CptanPanic commented 5 years ago

@CptanPanic Maybe I miss the point, but what's the use case of having data for a sleeping car ? (real question since I did not use the apiscraper a lot yet). Thx

To check for battery drain, cabin temps, etc.

wtran63 commented 5 years ago

When the car goes to sleep, the vehicle_data call is not available (cause your car is asleep and you get a 408 request timeout), so you wouldn't get that data until your car wakes up anyways.

The only data available is from the base vehicles call as found here: https://tesla-api.timdorr.com/api-basics/vehicles

egonzalezpozega commented 4 years ago

I just installed this 2 days ago. And it seems like this issue is still present on version 2019.5 I am currently on 2019.36.2.1 My car is constantly being polled every second and battery drain is pretty substantial since the car hasn’t gone to sleep. Only if I start the service while the car is asleep it will increase the polling interval. Once the car wakes up it will prevent it from going to sleep. According to the readme it should let the car go to sleep? Am I missing something?

rtega commented 4 years ago

See issue https://github.com/lephisto/tesla-apiscraper/issues/57 and the referred code https://github.com/lephisto/tesla-apiscraper/commit/91616525eff3b597927a3fe467b80ebc16fc3e0c. This solves it for me.

gaLDWoRE commented 4 years ago

Here to verify that the referred code that @rtega posted is all you need, resolved my issue last night.