Skip to content

Commit

Permalink
Iboost - fix issues with discharge on smart iboost plan (#1388)
Browse files Browse the repository at this point in the history
* Iboost - fix issues with discharge on smart iboost plan

#1364

* [pre-commit.ci lite] apply automatic fixes

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored Aug 24, 2024
1 parent 559642e commit 85e73e7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/predbat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@
"friendly_name": "iBoost max energy",
"type": "input_number",
"min": 0,
"max": 20,
"max": 30,
"step": 0.1,
"unit": "kWh",
"enable": "iboost_enable",
Expand All @@ -906,7 +906,7 @@
"friendly_name": "iBoost today",
"type": "input_number",
"min": 0,
"max": 5,
"max": 30,
"step": 0.1,
"unit": "kWh",
"enable": "iboost_enable",
Expand Down
47 changes: 41 additions & 6 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4481,9 +4481,12 @@ def publish_html_plan(self, pv_forecast_minute_step, pv_forecast_minute_step10,
)
else:
iboost_change = max(iboost_amount_end - iboost_amount, 0.0)
iboost_amount_str = str(self.dp2(iboost_change))
if iboost_change > 0:
iboost_color = "#FFFF00"
iboost_amount_str = str(self.dp2(iboost_amount)) + " (+" + str(self.dp2(iboost_change)) + ")"
else:
if iboost_amount > 0:
iboost_amount_str = str(self.dp2(iboost_amount))

if self.carbon_enable:
# Work out carbon intensity and carbon use
Expand Down Expand Up @@ -5286,6 +5289,7 @@ def reset(self):
if os.path.exists(root):
self.config_root = root
break
self.config_root_p = self.config_root
self.log("Config root is {}".format(self.config_root))

def optimise_charge_limit_price_threads(
Expand Down Expand Up @@ -5416,11 +5420,20 @@ def optimise_charge_limit_price_threads(

try_discharge[window_n] = 100
if window_n in all_d:
hit_charge = self.hit_charge_window(self.charge_window_best, discharge_window[window_n]["start"], discharge_window[window_n]["end"])
if not self.calculate_discharge_oncharge and hit_charge >= 0 and try_charge_limit[hit_charge] > 0.0:
continue
if not self.calculate_discharge_oncharge:
hit_charge = self.hit_charge_window(self.charge_window_best, discharge_window[window_n]["start"], discharge_window[window_n]["end"])
if hit_charge >= 0 and try_charge_limit[hit_charge] > 0.0:
continue
if not self.car_charging_from_battery and self.hit_car_window(discharge_window[window_n]["start"], discharge_window[window_n]["end"]):
continue
if (
not self.iboost_on_discharge
and self.iboost_enable
and self.iboost_plan
and (self.hit_charge_window(self.iboost_plan, discharge_window[window_n]["start"], discharge_window[window_n]["end"]) >= 0)
):
continue

if window_prices_discharge[window_n] < lowest_price_discharge:
lowest_price_discharge = window_prices_discharge[window_n]
try_discharge[window_n] = 0
Expand Down Expand Up @@ -6612,8 +6625,16 @@ def tweak_plan(self, end_record, best_metric, metric_keep):
hit_charge = self.hit_charge_window(self.charge_window_best, self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"])
if hit_charge >= 0 and self.charge_limit_best[hit_charge] > 0.0:
continue
if not self.car_charging_from_battery and self.hit_car_window(self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"]):
continue
if (
not self.iboost_on_discharge
and self.iboost_enable
and self.iboost_plan
and (self.hit_charge_window(self.iboost_plan, self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"]) >= 0)
):
continue
if not self.car_charging_from_battery and self.hit_car_window(self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"]):
continue

best_soc, best_start, best_metric, best_cost, soc_min, soc_min_minute, best_keep, best_cycle, best_carbon, best_import = self.optimise_discharge(
window_n,
record_discharge_windows,
Expand Down Expand Up @@ -6880,6 +6901,13 @@ def optimise_all_windows(self, best_metric, metric_keep):
self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"]
):
continue
if (
not self.iboost_on_discharge
and self.iboost_enable
and self.iboost_plan
and (self.hit_charge_window(self.iboost_plan, self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"]) >= 0)
):
continue

average = self.discharge_window_best[window_n]["average"]
if price < lowest_price_charge:
Expand Down Expand Up @@ -7002,6 +7030,13 @@ def optimise_all_windows(self, best_metric, metric_keep):
continue
if not self.car_charging_from_battery and self.hit_car_window(self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"]):
continue
if (
not self.iboost_on_discharge
and self.iboost_enable
and self.iboost_plan
and (self.hit_charge_window(self.iboost_plan, self.discharge_window_best[window_n]["start"], self.discharge_window_best[window_n]["end"]) >= 0)
):
continue

average = self.discharge_window_best[window_n]["average"]
best_soc, best_start, best_metric, best_cost, soc_min, soc_min_minute, best_keep, best_cycle, best_carbon, best_import = self.optimise_discharge(
Expand Down

0 comments on commit 85e73e7

Please sign in to comment.