From 239959722c1ec7d87d40090552d6ce7a02f54bc2 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sun, 7 Jan 2024 18:31:53 +0000 Subject: [PATCH] Fix to avoid crash if car charging plan time is not set correctly --- apps/predbat/predbat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index c09194842..b47f556ef 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -4914,7 +4914,12 @@ def plan_car_charging(self, car_n, low_rates): else: price_sorted = [n for n in range(0, len(low_rates))] - ready_time = datetime.strptime(self.car_charging_plan_time[car_n], "%H:%M:%S") + try: + ready_time = datetime.strptime(self.car_charging_plan_time[car_n], "%H:%M:%S") + except ValueError: + ready_time = datetime.strptime("07:00:00", "%H:%M:%S") + self.log("WARN: Car charging plan time for car {} is invalid".format(car_n)) + ready_minutes = ready_time.hour * 60 + ready_time.minute # Ready minutes wrap?