Skip to content

Commit

Permalink
Don't enable low power in monitor mode (#1841)
Browse files Browse the repository at this point in the history
* Don't enable low power in monitor mode

#1816

* [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 Jan 4, 2025
1 parent 7ee7fe6 commit f7e7e4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/predbat/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self, base=None, pv_forecast_minute_step=None, pv_forecast_minute10
self.set_discharge_during_charge = base.set_discharge_during_charge
self.set_read_only = base.set_read_only
self.set_charge_low_power = base.set_charge_low_power
self.set_charge_window = base.set_charge_window
self.charge_low_power_margin = base.charge_low_power_margin
self.car_charging_slots = base.car_charging_slots
self.car_charging_limit = base.car_charging_limit
Expand Down Expand Up @@ -642,7 +643,7 @@ def run_prediction(self, charge_limit, charge_window, export_window, export_limi
four_hour_rule = False
elif (charge_window_n >= 0) and soc < charge_limit_n:
# Charge enable
if save in ["best", "best10", "test"]:
if self.set_charge_window and (save in ["best", "best10", "test"]):
# Only tune charge rate on final plan not every simulation
charge_rate_now = find_charge_rate(
minute_absolute,
Expand Down
13 changes: 13 additions & 0 deletions apps/predbat/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,8 @@ def simple_scenario(
assert_iboost_running_full=False,
car_soc=0,
car_limit=100,
set_charge_low_power=False,
set_charge_window=True,
):
"""
No PV, No Load
Expand All @@ -1463,6 +1465,8 @@ def simple_scenario(
my_predbat.battery_rate_max_charge_scaled = battery_rate_max_charge / 60.0
my_predbat.battery_rate_max_discharge_scaled = battery_rate_max_charge / 60.0
my_predbat.car_charging_from_battery = car_charging_from_battery
my_predbat.set_charge_low_power = set_charge_low_power
my_predbat.set_charge_window = set_charge_window

my_predbat.iboost_enable = iboost_enable
my_predbat.iboost_gas = iboost_gas
Expand Down Expand Up @@ -4721,6 +4725,15 @@ def run_model_tests(my_predbat):
)
failed |= simple_scenario("pv_only_bat_dc_export_limit_load", my_predbat, 0.5, 3, assert_final_metric=-export_rate * 24 * 0.5, assert_final_soc=24, with_battery=True, hybrid=True, export_limit=0.5)
failed |= simple_scenario("battery_charge", my_predbat, 0, 0, assert_final_metric=import_rate * 10, assert_final_soc=10, with_battery=True, charge=10, battery_size=10)

failed |= simple_scenario("battery_charge_low_off", my_predbat, 0, 0, assert_final_metric=import_rate * 10, assert_final_soc=10, with_battery=True, charge=10, battery_size=10, set_charge_low_power=False, keep=5, assert_keep=24.59)
failed |= simple_scenario("battery_charge_low_on", my_predbat, 0, 0, assert_final_metric=import_rate * 10, assert_final_soc=10, with_battery=True, charge=10, battery_size=10, set_charge_low_power=True, keep=5, assert_keep=88.89)
failed |= simple_scenario(
"battery_charge_low_on_monitor", my_predbat, 0, 0, assert_final_metric=import_rate * 10, assert_final_soc=10, with_battery=True, charge=10, battery_size=10, set_charge_low_power=True, keep=5, assert_keep=24.59, set_charge_window=False
)

if failed:
return failed
failed |= simple_scenario("battery_charge_prev_charge", my_predbat, 0, 0, assert_final_metric=import_rate * 10, assert_final_soc=10, with_battery=True, charge=10, battery_size=10)

failed |= simple_scenario(
Expand Down

0 comments on commit f7e7e4a

Please sign in to comment.