diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 17a105cd..d888f89a 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -24,9 +24,11 @@ try: import adbase as ad import appdaemon.plugins.hass.hassapi as hass + IS_APPDAEMON = True except: import hass as hass + IS_APPDAEMON = False import pytz diff --git a/apps/predbat/unit_test.py b/apps/predbat/unit_test.py index 14eb2e03..f6622bf7 100644 --- a/apps/predbat/unit_test.py +++ b/apps/predbat/unit_test.py @@ -907,8 +907,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.combine_export_slots = False + # my_predbat.best_soc_keep = 1.0 my_predbat.metric_min_improvement_export = 5 if re_do_rates: @@ -953,13 +953,13 @@ def run_single_debug(my_predbat, debug_file): load_forecast=my_predbat.load_forecast, load_scaling_dynamic=my_predbat.load_scaling_dynamic, cloud_factor=min(my_predbat.metric_load_divergence + 0.5, 1.0) if my_predbat.metric_load_divergence else None, - ) + ) pv_step = my_predbat.pv_forecast_minute_step pv10_step = my_predbat.pv_forecast_minute10_step load_step = my_predbat.load_minutes_step load10_step = my_predbat.load_minutes_step10 - + my_predbat.prediction = Prediction(my_predbat, pv_step, pv_step, load_step, load_step) my_predbat.debug_enable = True @@ -1048,7 +1048,6 @@ def run_single_debug(my_predbat, debug_file): print("Wrote plan to plan_final.html") - def run_execute_tests(my_predbat): print("**** Running execute tests ****\n") reset_inverter(my_predbat) @@ -1299,22 +1298,22 @@ def run_execute_tests(my_predbat): return failed my_predbat.battery_charge_power_curve = { - 100 : 0.50, - 99 : 0.50, - 98 : 0.50, - 97 : 0.50, - 96 : 0.50, - 95 : 0.50, - 94 : 1.00, - 93 : 1.00, - 92 : 1.00, - 91 : 1.00, - 90 : 1.00, - 89 : 1.00, - 88 : 1.00, - 87 : 1.00, - 86 : 1.00, - 85 : 1.00, + 100: 0.50, + 99: 0.50, + 98: 0.50, + 97: 0.50, + 96: 0.50, + 95: 0.50, + 94: 1.00, + 93: 1.00, + 92: 1.00, + 91: 1.00, + 90: 1.00, + 89: 1.00, + 88: 1.00, + 87: 1.00, + 86: 1.00, + 85: 1.00, } # 60 minutes - 10 minute margin = 50 minutes to add 0.75kWh to each battery (x2 inverters) @@ -2941,10 +2940,10 @@ def run_model_tests(my_predbat): failed |= simple_scenario("load_only", my_predbat, 1, 0, assert_final_metric=import_rate * 24, assert_final_soc=0, with_battery=False) failed |= simple_scenario("load_bat_ac", my_predbat, 4, 0, assert_final_metric=import_rate * 24 * 3.2, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8) failed |= simple_scenario("load_bat_dc", my_predbat, 4, 0, assert_final_metric=import_rate * 24 * 3.2, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8, hybrid=True) - failed |= simple_scenario("load_bat_ac2", my_predbat, 0.5, 0, assert_final_metric=0, assert_final_soc=100 - 12/0.8, with_battery=True, battery_soc=100.0, inverter_loss=0.8) - failed |= simple_scenario("load_bat_dc2", my_predbat, 0.5, 0, assert_final_metric=0, assert_final_soc=100 - 12/0.8, with_battery=True, battery_soc=100.0, inverter_loss=0.8, hybrid=True) - failed |= simple_scenario("load_bat_ac3", my_predbat, 1.0, 0, assert_final_metric=import_rate * 0.2*24, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8) - failed |= simple_scenario("load_bat_dc3", my_predbat, 1.0, 0, assert_final_metric=import_rate * 0.2*24, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8, hybrid=True) + failed |= simple_scenario("load_bat_ac2", my_predbat, 0.5, 0, assert_final_metric=0, assert_final_soc=100 - 12 / 0.8, with_battery=True, battery_soc=100.0, inverter_loss=0.8) + failed |= simple_scenario("load_bat_dc2", my_predbat, 0.5, 0, assert_final_metric=0, assert_final_soc=100 - 12 / 0.8, with_battery=True, battery_soc=100.0, inverter_loss=0.8, hybrid=True) + failed |= simple_scenario("load_bat_ac3", my_predbat, 1.0, 0, assert_final_metric=import_rate * 0.2 * 24, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8) + failed |= simple_scenario("load_bat_dc3", my_predbat, 1.0, 0, assert_final_metric=import_rate * 0.2 * 24, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8, hybrid=True) failed |= simple_scenario( "load_bat_dc_pv", @@ -4140,7 +4139,6 @@ def main(): parser = argparse.ArgumentParser(description="Predbat unit tests") parser.add_argument("--debug_file", action="store", help="Enable debug output") args = parser.parse_args() - print("**** Starting Predbat tests ****") my_predbat = PredBat()