dbweb-ch / ioBroker.tesla-motors

ioBroker Adapter for Tesla Motors Cars
MIT License
11 stars 9 forks source link

Adapter prevents car from sleeping in "smart" mode #59

Closed trollvottel closed 3 years ago

trollvottel commented 3 years ago

The adapter kept my car online the whole night (0:00-8:30), even in "smart" mode. Please see logs attached, it says each time it's getting all data because last wake was just a minute ago. I'm disabling the adapter for now, because its useless to me like that ATM as the car wastes A LOT of energy when awake (>5% per night). iobroker.2021-04-07.log

trollvottel commented 3 years ago

I guess the bug lies here:

https://github.com/dbweb-ch/ioBroker.tesla-motors/blob/cdfac2bb8961591829f057a4640e49f06dbb026a/main.js#L148

Since the task is re-scheduled every second, at some point a minute has passed which is <10 minutes where everything is re-read.

dbweb-ch commented 3 years ago

Minutes is the time passed since the car last time changed its state from sleeping to wake up. In addition, this get's reset when the car is in use (Checking shift_state, charge_state, speed and climate). The task is rescheduled every 5 seconds (ignore the misleading comment in the code, need to remove that), but if the "Minute" goes higher than 10 it trys to let the car fall asleep by not requesting infos for the next 15 minutes anymore. Somehow your adapter did reset the "lastTimeWokeUp" and because of that, it did never go to sleep.

I've just pushed a version with additional logging at the places where "lastTimeWokeUp" get reset. Could you install the newest version from github and if the car does not go to sleep, send me the corresponding logfile?

trollvottel commented 3 years ago

Will do, installing right now..

trollvottel commented 3 years ago

I guess it has sth. to do with the fact that I leave the car plugged in over night (without actually charging due to photovoltaics-optimized charging)

dbweb-ch commented 3 years ago

Ah, then you should already be ok with the last latest version. The state of the charger in that case is "Stopped", I've included this because of a request from another user a couple of days ago, so in case it is "Stopped", it does not reset the time and should also go asleep. Just take the latest version from github.

trollvottel commented 3 years ago

Indeed the case is "Stopped" when plugged in over night without charging. Thanks!