From 6d97cd15876a2f1e68c2f35b97f8cb34ef8e0bbc Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Wed, 7 Jun 2023 08:46:41 +0100 Subject: [PATCH] Fix crash when on a fixed rate tariff If there are no charge windows then don't optimise any --- 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 6061cb6e..fd536b1e 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -2297,7 +2297,7 @@ def update_pred(self): metric, self.charge_limit_percent, import_kwh_battery, import_kwh_house, export_kwh, soc_min, soc, soc_min_minute = self.run_prediction(self.charge_limit, self.charge_window, self.discharge_window, self.discharge_limits, load_minutes, pv_forecast_minute, save='base', end_record=end_record) # Try different battery SOCs to get the best result - if self.get_arg('calculate_best', False): + if self.get_arg('calculate_best', False) and self.charge_window_best: record_charge_windows = max(self.max_charge_windows(end_record + self.minutes_now, self.charge_window_best), 1) self.log("Record charge windows is {} end_record_abs was {}".format(record_charge_windows, self.time_abs_str(end_record + self.minutes_now)))