Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Jan 26, 2024
1 parent 5face58 commit 6688d97
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4857,11 +4857,7 @@ def find_charge_window(self, rates, minute, threshold_rate, find_high):
# If combine is disabled, for import slots make them all N minutes so we can select some not all
rate_low_end = minute
break
if (
(rate_low_start in self.manual_all_times or minute in self.manual_all_times)
and (rate_low_start >= 0)
and ((minute - rate_low_start) >= 30)
):
if (rate_low_start in self.manual_all_times or minute in self.manual_all_times) and (rate_low_start >= 0) and ((minute - rate_low_start) >= 30):
# Manual slot
rate_low_end = minute
break
Expand Down Expand Up @@ -6781,7 +6777,14 @@ def optimise_charge_limit_price(

# Simulate with medium PV
metricmid, import_kwh_battery, import_kwh_house, export_kwh, soc_min, soc, soc_min_minute, battery_cycle, metric_keep, final_iboost = self.run_prediction(
try_charge_limit, charge_window, discharge_window, try_discharge, load_minutes_step, pv_forecast_minute_step, end_record=end_record, step=step,
try_charge_limit,
charge_window,
discharge_window,
try_discharge,
load_minutes_step,
pv_forecast_minute_step,
end_record=end_record,
step=step,
)

# Debug re-enable if it was on
Expand Down Expand Up @@ -7510,7 +7513,13 @@ def discard_unused_charge_slots(self, charge_limit_best, charge_window_best, res
end = window["end"]
limit = charge_limit_best[window_n]

if new_window_best and (start == new_window_best[-1]["end"]) and (limit == new_limit_best[-1]) and (start not in self.manual_all_times) and (new_window_best[-1]["start"] not in self.manual_all_times):
if (
new_window_best
and (start == new_window_best[-1]["end"])
and (limit == new_limit_best[-1])
and (start not in self.manual_all_times)
and (new_window_best[-1]["start"] not in self.manual_all_times)
):
new_window_best[-1]["end"] = end
if self.debug_enable:
self.log(
Expand Down Expand Up @@ -7717,7 +7726,13 @@ def discard_unused_discharge_slots(self, discharge_limits_best, discharge_window
for window_n in range(0, len(discharge_limits_best)):
if discharge_limits_best[window_n] < 100.0:
# Also merge contiguous enabled windows
if new_best and (discharge_window_best[window_n]["start"] == new_best[-1]["end"]) and (discharge_limits_best[window_n] == new_enable[-1]) and (discharge_window_best[window_n]["start"] not in self.manual_all_times) and (new_best[-1]["start"] not in self.manual_all_times):
if (
new_best
and (discharge_window_best[window_n]["start"] == new_best[-1]["end"])
and (discharge_limits_best[window_n] == new_enable[-1])
and (discharge_window_best[window_n]["start"] not in self.manual_all_times)
and (new_best[-1]["start"] not in self.manual_all_times)
):
new_best[-1]["end"] = discharge_window_best[window_n]["end"]
if self.debug_enable:
self.log("Combine discharge slot {} with previous - percent {} slot {}".format(window_n, new_enable[-1], new_best[-1]))
Expand Down Expand Up @@ -7913,7 +7928,11 @@ def optimise_all_windows(self, load_minutes_step, load_minutes_step10, pv_foreca

if self.calculate_best_charge and (window_start not in self.manual_all_times):
if not printed_set:
self.log("Optimise price set {} start_at_low {} best_price {} best_metric {} best_cost {}".format(price, start_at_low, best_price, self.dp2(best_metric), self.dp2(best_cost)))
self.log(
"Optimise price set {} start_at_low {} best_price {} best_metric {} best_cost {}".format(
price, start_at_low, best_price, self.dp2(best_metric), self.dp2(best_cost)
)
)
printed_set = True
average = self.charge_window_best[window_n]["average"]

Expand Down Expand Up @@ -7979,7 +7998,11 @@ def optimise_all_windows(self, load_minutes_step, load_minutes_step10, pv_foreca
continue

if not printed_set:
self.log("Optimise price set {} start_at_low {} best_price {} best_metric {} best_cost {}".format(price, start_at_low, best_price, self.dp2(best_metric), self.dp2(best_cost)))
self.log(
"Optimise price set {} start_at_low {} best_price {} best_metric {} best_cost {}".format(
price, start_at_low, best_price, self.dp2(best_metric), self.dp2(best_cost)
)
)
printed_set = True

best_soc, best_start, best_metric, best_cost, soc_min, soc_min_minute, best_keep = self.optimise_discharge(
Expand Down

0 comments on commit 6688d97

Please sign in to comment.