Skip to content

Commit 3803e2f

Browse files
Fix crash in discharge mode only (no charging)
With discharge only mode there was an undefined variable crash
1 parent ee558c9 commit 3803e2f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

apps/predbat/predbat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ def update_pred(self):
22982298
best_discharge, best_metric, best_cost, soc_min, soc_min_minute = self.optimise_discharge(0, record_discharge_windows, self.charge_limit_best, self.charge_window_best, self.discharge_window_best, self.discharge_limits_best, load_minutes, pv_forecast_minute, pv_forecast_minute10, all_n = record_discharge_windows, end_record = end_record)
22992299

23002300
self.discharge_limits_best = [best_discharge if n < record_discharge_windows else 100.0 for n in range(0, len(self.discharge_limits_best))]
2301-
self.log("Best all discharge limit all windows n={} (adjusted) discharge limit {} soc calculated at {} min {} @ {} (margin added {} and min {}) with metric {} cost {} windows {}".format(record_discharge_windows, best_discharge, self.dp2(best_soc), self.dp2(soc_min), self.time_abs_str(soc_min_minute), self.best_soc_margin, self.best_soc_min, self.dp2(best_metric), self.dp2(best_cost), self.charge_limit_best))
2301+
self.log("Best all discharge limit all windows n={} (adjusted) discharge limit {} min {} @ {} (margin added {} and min {}) with metric {} cost {} windows {}".format(record_discharge_windows, best_discharge, self.dp2(soc_min), self.time_abs_str(soc_min_minute), self.best_soc_margin, self.best_soc_min, self.dp2(best_metric), self.dp2(best_cost), self.charge_limit_best))
23022302

23032303
if record_discharge_windows > 1:
23042304
# Optimise in price order, most expensive first try to increase each one, only required for more than 1 window
@@ -2308,7 +2308,7 @@ def update_pred(self):
23082308

23092309
self.discharge_limits_best[window_n] = best_discharge
23102310
if self.debug_enable or 1:
2311-
self.log("Best discharge limit window {} discharge {} (adjusted) soc calculated at {} min {} @ {} (margin added {} and min {}) with metric {} cost {}".format(window_n, best_discharge, self.dp2(best_soc), self.dp2(soc_min), self.time_abs_str(soc_min_minute), self.best_soc_margin, self.best_soc_min, self.dp2(best_metric), self.dp2(best_cost)))
2311+
self.log("Best discharge limit window {} discharge {} (adjusted) min {} @ {} (margin added {} and min {}) with metric {} cost {}".format(window_n, best_discharge, self.dp2(soc_min), self.time_abs_str(soc_min_minute), self.best_soc_margin, self.best_soc_min, self.dp2(best_metric), self.dp2(best_cost)))
23122312

23132313
if self.get_arg('calculate_best', False):
23142314
# Final simulation of best, do 10% and normal scenario

0 commit comments

Comments
 (0)