From 731cf808c9e7e44444ead2cf0461cb950b279475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Br=C3=BCggemann?= Date: Sun, 10 Apr 2022 15:14:12 +0200 Subject: [PATCH] Fix overly long line --- psa_car_controller/psacc/application/charge_control.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/psa_car_controller/psacc/application/charge_control.py b/psa_car_controller/psacc/application/charge_control.py index 1c9ceff..0ad8193 100644 --- a/psa_car_controller/psacc/application/charge_control.py +++ b/psa_car_controller/psacc/application/charge_control.py @@ -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