diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 56e48ee7..d888f89a 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -38,7 +38,7 @@ import asyncio import json -THIS_VERSION = "v8.8.5" +THIS_VERSION = "v8.8.6" # 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"] diff --git a/apps/predbat/prediction.py b/apps/predbat/prediction.py index 8184ed9f..54fad279 100644 --- a/apps/predbat/prediction.py +++ b/apps/predbat/prediction.py @@ -586,11 +586,7 @@ def run_prediction(self, charge_limit, charge_window, export_window, export_limi if export_window_n >= 0: discharge_min = max(self.soc_max * export_limits[export_window_n] / 100.0, self.reserve, self.best_soc_min) - if not self.set_export_freeze_only and (export_window_n >= 0) and export_limits[export_window_n] < 100.0 and (soc - step * self.battery_rate_max_discharge_scaled) < discharge_min: - # Export runs out of battery - give penalty for this case, we might not stop it in time - metric_keep += step * self.battery_rate_max_discharge_scaled * rate_import.get(minute_absolute, 0) * 0.5 - - if not self.set_export_freeze_only and (export_window_n >= 0) and export_limits[export_window_n] < 100.0 and (soc - step * self.battery_rate_max_discharge_scaled) >= discharge_min: + if not self.set_export_freeze_only and (export_window_n >= 0) and export_limits[export_window_n] < 99.0 and (soc - step * self.battery_rate_max_discharge_scaled) >= discharge_min: # Discharge enable discharge_rate_now = self.battery_rate_max_discharge # Assume discharge becomes enabled here discharge_rate_now_curve = get_discharge_rate_curve(soc, discharge_rate_now, self.soc_max, self.battery_rate_max_discharge, self.battery_discharge_power_curve, self.battery_rate_min) * self.battery_rate_max_scaling_discharge diff --git a/apps/predbat/unit_test.py b/apps/predbat/unit_test.py index aaa91a06..f6622bf7 100644 --- a/apps/predbat/unit_test.py +++ b/apps/predbat/unit_test.py @@ -908,7 +908,8 @@ def run_single_debug(my_predbat, debug_file): # Force off combine export XXX: print("Combined export slots {}".format(my_predbat.combine_export_slots)) # my_predbat.combine_export_slots = False - my_predbat.best_soc_keep = 1.0 + # my_predbat.best_soc_keep = 1.0 + my_predbat.metric_min_improvement_export = 5 if re_do_rates: # Find discharging windows @@ -2436,7 +2437,7 @@ def run_optimise_all_windows( expect_export_limit=[], expect_best_price=0.0, rate_import=10.0, - rate_export=5.0, + rate_export=5.5, battery_size=100.0, battery_soc=0.0, hybrid=False, @@ -3384,7 +3385,7 @@ def run_model_tests(my_predbat): with_battery=True, discharge=0, battery_soc=10, - assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE, + assert_keep=1 * import_rate * KEEP_SCALE, keep=1.0, ) failed |= simple_scenario( @@ -3397,7 +3398,7 @@ def run_model_tests(my_predbat): with_battery=True, discharge=0, battery_soc=10, - assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE, + assert_keep=1 * import_rate * KEEP_SCALE, keep=1.0, save="test", ) @@ -3411,7 +3412,7 @@ def run_model_tests(my_predbat): with_battery=True, discharge=0, battery_soc=10, - assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE, + assert_keep=1 * import_rate * KEEP_SCALE, keep=1.0, save="none", ) @@ -4056,7 +4057,7 @@ def run_model_tests(my_predbat): battery_size=10, keep=1.0, assert_final_iboost=0, - assert_keep=import_rate * 14 * 0.5 * KEEP_SCALE + import_rate * 1 * KEEP_SCALE, + assert_keep=import_rate * 1 * KEEP_SCALE, ) # Alternating high/low rates