Fix overly long line

This commit is contained in:
Christian Brüggemann
2022-04-10 15:14:12 +02:00
parent 0bd05d95f7
commit 731cf808c9
@@ -83,10 +83,12 @@ class ChargeControl:
vehicle_status = self.psacc.vehicles_list.get_car_by_vin(self.vin).get_status()
status = vehicle_status.get_energy('Electric').charging.status
level = vehicle_status.get_energy('Electric').level
if status == INPROGRESS and self.percentage_threshold < 100:
has_threshold = self.percentage_threshold < 100
hit_threshold = level >= self.percentage_threshold
if status == INPROGRESS and has_threshold:
logger.info("charging status of %s is %s, battery level: %d", self.vin, status, level)
self.force_update(vehicle_status)
if level >= self.percentage_threshold and self.retry_count < 2:
if hit_threshold and self.retry_count < 2:
logger.info("Charge threshold is reached, stop the charge")
self.control_charge_with_ack(False)
elif self._next_stop_hour is not None:
@@ -101,7 +103,7 @@ class ChargeControl:
thread = threading.Timer(periodicity, self.process)
thread.setDaemon(True)
thread.start()
elif status == STOPPED and self.percentage_threshold < 100 and level >= self.percentage_threshold and self.__is_approaching_scheduled_time(now):
elif status == STOPPED and has_threshold and hit_threshold and self.__is_approaching_scheduled_time(now):
logger.info("Approaching scheduled charging time, but should not charge. Postponing charge hour!")
self.force_update(vehicle_status)
hour = now.hour - 1 if now.hour > 0 else 23