Skip to content

Commit

Permalink
Fix for issues with charge freeze disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
springfall2008 authored Dec 20, 2024
1 parent 924be68 commit b8a5dde
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/predbat/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def execute_plan(self):
discharge_soc = max((self.export_limits_best[0] * self.soc_max) / 100.0, self.reserve, self.best_soc_min)
self.log("Next export window will be: {} - {} at reserve {}".format(discharge_start_time, discharge_end_time, self.export_limits_best[0]))
if (self.minutes_now >= minutes_start) and (self.minutes_now < minutes_end) and (self.export_limits_best[0] < 100.0):
if not self.set_export_freeze_only and ((self.soc_kw - PREDICT_STEP * inverter.battery_rate_max_discharge_scaled) >= discharge_soc):
if not self.set_export_freeze_only and self.export_limits_best[0] < 99.0 and ((self.soc_kw - PREDICT_STEP * inverter.battery_rate_max_discharge_scaled) >= discharge_soc):
self.log("Exporting now - current SoC {} and target {}".format(self.soc_kw, dp2(discharge_soc)))
inverter.adjust_discharge_rate(inverter.battery_rate_max_discharge * MINUTE_WATT)
resetDischarge = False
Expand All @@ -297,7 +297,7 @@ def execute_plan(self):
else:
inverter.adjust_force_export(False)
disabled_export = True
if self.export_limits_best[0] == 99:
if self.set_export_freeze and self.export_limits_best[0] == 99:
# In export freeze mode we disable charging during export slots
if inverter.inv_charge_discharge_with_rate:
inverter.adjust_charge_rate(0)
Expand Down
10 changes: 8 additions & 2 deletions apps/predbat/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ def optimise_charge_limit_price_threads(

for loop_price in all_prices:
pred_table = []
freeze_options = [True, False]
if self.set_export_freeze:
freeze_options = [True, False]
else:
freeze_options = [False]
for freeze in freeze_options:
for modulo in [2, 3, 4, 6, 8, 16, 32]:
for divide in [96, 48, 32, 16, 8, 4, 3, 2, 1]:
Expand Down Expand Up @@ -1991,7 +1994,10 @@ def optimise_all_windows(self, best_metric, metric_keep, debug_mode=False):
record_charge_windows = max(self.max_charge_windows(self.end_record + self.minutes_now, self.charge_window_best), 1)
record_export_windows = max(self.max_charge_windows(self.end_record + self.minutes_now, self.export_window_best), 1)
window_sorted, window_index, price_set, price_links = self.sort_window_by_price_combined(
self.charge_window_best[:record_charge_windows], self.export_window_best[:record_export_windows], calculate_import_low_export=self.calculate_import_low_export, calculate_export_low_import=self.calculate_export_low_import
self.charge_window_best[:record_charge_windows],
self.export_window_best[:record_export_windows],
calculate_import_low_export=self.calculate_import_low_export,
calculate_export_low_import=self.calculate_export_low_import
)

self.rate_best_cost_threshold_charge = best_price
Expand Down
2 changes: 1 addition & 1 deletion apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import asyncio
import json

THIS_VERSION = "v8.8.10"
THIS_VERSION = "v8.8.11"

# fmt: off
PREDBAT_FILES = ["predbat.py", "config.py", "prediction.py", "gecloud.py","utils.py", "inverter.py", "ha.py", "download.py", "unit_test.py", "web.py", "predheat.py", "futurerate.py", "octopus.py", "solcast.py","execute.py", "plan.py", "fetch.py", "output.py", "userinterface.py"]
Expand Down
2 changes: 1 addition & 1 deletion apps/predbat/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def run_prediction(self, charge_limit, charge_window, export_window, export_limi
if self.set_export_freeze:
charge_rate_now = self.battery_rate_max_charge
# Freeze mode
if (export_window_n >= 0) and (export_limits[export_window_n] == 99.0 or self.set_export_freeze_only):
if (export_window_n >= 0) and (self.set_export_freeze and (export_limits[export_window_n] == 99.0 or self.set_export_freeze_only)):
charge_rate_now = self.battery_rate_min # 0

# Set discharge during charge?
Expand Down
6 changes: 5 additions & 1 deletion apps/predbat/userinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,13 @@ def read_debug_yaml(self, filename):
if key not in ["CONFIG_ITEMS", "inverters"]:
self.__dict__[key] = copy.deepcopy(debug[key])
if key == "inverters":
new_inverters = []
for inverter in debug[key]:
inverter_obj = copy.deepcopy(self.inverters[0])
for key in inverter:
self.inverters[inverter["id"]].__dict__[key] = copy.deepcopy(inverter[key])
inverter_obj.__dict__[key] = copy.deepcopy(inverter[key])
new_inverters.append(inverter_obj)
self.inverters = new_inverters

for item in debug["CONFIG_ITEMS"]:
current = self.config_index.get(item["name"], None)
Expand Down

0 comments on commit b8a5dde

Please sign in to comment.