fix charge controlv3

This commit is contained in:
Florian Bezannier
2020-12-31 00:51:40 +01:00
parent 83cb4853fa
commit 10d64b0f07
+5 -2
View File
@@ -5,6 +5,9 @@ from copy import copy
from datetime import datetime, timedelta
from hashlib import md5
from time import sleep
import pytz
from MyPSACC import MyPSACC
from MyLogger import logger
from psa_connectedcar.rest import ApiException
@@ -56,8 +59,8 @@ class ChargeControl:
logger.info(f"charging status of {self.vin} is {status}, battery level: {level}")
if status == "InProgress":
# force update if the car doesn't send info during 10 minutes
last_update = res.energy[0].updated_at
if (datetime.utcnow() - last_update).total_seconds() > 60 * 10:
last_update = res.energy[0].updated_at.replace(tzinfo=pytz.UTC)
if (datetime.utcnow().replace(tzinfo=None) - last_update).total_seconds() > 60 * 10:
self.psacc.wakeup(self.vin)
if (level >= self.percentage_threshold and self.retry_count < 2) or stop_charge:
self.psacc.charge_now(self.vin, False)