From 65b5dc75eebf301953ca7981cf0bf82a3dcbb2d9 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Mon, 10 Jul 2023 08:24:36 +0100 Subject: [PATCH] Fix crash in discharge_unused_charge_windows --- apps/predbat/predbat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index d839fe8dd..bf40792fd 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -2822,7 +2822,7 @@ def discard_unused_charge_slots(self, charge_limit_best, charge_window_best, res window = charge_window_best[window_n] start = window['start'] end = window['end'] - if (charge_limit_best[window_n] > self.dp2(reserve)) or (self.minutes_now >= start and self.minutes_now < end and self.charge_limit and self.charge_limit[0]['end'] == end): + if (charge_limit_best[window_n] > self.dp2(reserve)) or (self.minutes_now >= start and self.minutes_now < end and self.charge_window and self.charge_window[0]['end'] == end): new_limit_best.append(charge_limit_best[window_n]) new_window_best.append(charge_window_best[window_n]) return new_limit_best, new_window_best