Skip to content

Commit

Permalink
Merge pull request #321 from GeoDerp/list_set_deferrable_startup_pena…
Browse files Browse the repository at this point in the history
…lty-support

def_start_penalty add optional support
  • Loading branch information
davidusb-geek authored Jul 6, 2024
2 parents 9e1636d + 9d243b0 commit 1109aec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ See bellow for a list of associations between the parameters from `config_emhass
| optim_conf | def_total_hours | list_operating_hours_of_each_deferrable_load | operating_hours_of_each_deferrable_load |
| optim_conf | treat_def_as_semi_cont | list_treat_deferrable_load_as_semi_cont | treat_deferrable_load_as_semi_cont |
| optim_conf | set_def_constant | list_set_deferrable_load_single_constant | set_deferrable_load_single_constant |
| optim_conf | def_start_penalty | list_set_deferrable_startup_penalty | set_deferrable_startup_penalty |
| optim_conf | weather_forecast_method | weather_forecast_method | |
| optim_conf | load_forecast_method | load_forecast_method | |
| optim_conf | delta_forecast | delta_forecast_daily | |
Expand Down
17 changes: 10 additions & 7 deletions src/emhass/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@ def build_params(params: dict, params_secrets: dict, options: dict, addon: int,
params["optim_conf"]["def_total_hours"] = [i["operating_hours_of_each_deferrable_load"] for i in options.get("list_operating_hours_of_each_deferrable_load")]
if options.get("list_treat_deferrable_load_as_semi_cont", None) != None:
params["optim_conf"]["treat_def_as_semi_cont"] = [i["treat_deferrable_load_as_semi_cont"] for i in options.get("list_treat_deferrable_load_as_semi_cont")]
if options.get("list_set_deferrable_load_single_constant", None) != None:
params["optim_conf"]["set_def_constant"] = [i["set_deferrable_load_single_constant"] for i in options.get("list_set_deferrable_load_single_constant")]
if options.get("list_set_deferrable_startup_penalty", None) != None:
params["optim_conf"]["def_start_penalty"] = [i["set_deferrable_startup_penalty"] for i in options.get("list_set_deferrable_startup_penalty")]
params["optim_conf"]["weather_forecast_method"] = options.get("weather_forecast_method", params["optim_conf"]["weather_forecast_method"])
# Update optional param secrets
if params["optim_conf"]["weather_forecast_method"] == "solcast":
Expand All @@ -817,12 +821,6 @@ def build_params(params: dict, params_secrets: dict, options: dict, addon: int,
params["optim_conf"]["load_forecast_method"] = options.get("load_forecast_method", params["optim_conf"]["load_forecast_method"])
params["optim_conf"]["delta_forecast"] = options.get("delta_forecast_daily", params["optim_conf"]["delta_forecast"])
params["optim_conf"]["load_cost_forecast_method"] = options.get("load_cost_forecast_method", params["optim_conf"]["load_cost_forecast_method"])
if options.get("list_set_deferrable_load_single_constant", None) != None:
params["optim_conf"]["set_def_constant"] = [i["set_deferrable_load_single_constant"] for i in options.get("list_set_deferrable_load_single_constant")]

if options.get("list_set_deferrable_startup_penalty", None) != None:
params["optim_conf"]["def_start_penalty"] = [i["set_deferrable_startup_penalty"] for i in options.get("list_set_deferrable_startup_penalty")]

if (options.get("list_peak_hours_periods_start_hours", None) != None and options.get("list_peak_hours_periods_end_hours", None) != None):
start_hours_list = [i["peak_hours_periods_start_hours"] for i in options["list_peak_hours_periods_start_hours"]]
end_hours_list = [i["peak_hours_periods_end_hours"] for i in options["list_peak_hours_periods_end_hours"]]
Expand Down Expand Up @@ -889,7 +887,12 @@ def build_params(params: dict, params_secrets: dict, options: dict, addon: int,
if params['optim_conf']['num_def_loads'] is not len(params['optim_conf']['treat_def_as_semi_cont']):
logger.warning("treat_def_as_semi_cont / list_treat_deferrable_load_as_semi_cont does not match number in num_def_loads, adding default values to parameter")
for x in range(len(params['optim_conf']['treat_def_as_semi_cont']), params['optim_conf']['num_def_loads']):
params['optim_conf']['treat_def_as_semi_cont'].append(True)
params['optim_conf']['treat_def_as_semi_cont'].append(True)
if params['optim_conf']['num_def_loads'] is not len(params['optim_conf']['def_start_penalty']):
logger.warning("def_start_penalty / list_set_deferrable_startup_penalty does not match number in num_def_loads, adding default values to parameter")
for x in range(len(params['optim_conf']['def_start_penalty']), params['optim_conf']['num_def_loads']):
params['optim_conf']['def_start_penalty'].append(0.0)
# days_to_retrieve should be no less then 2
if params['optim_conf']['num_def_loads'] is not len(params['optim_conf']['def_total_hours']):
logger.warning("def_total_hours / list_operating_hours_of_each_deferrable_load does not match number in num_def_loads, adding default values to parameter")
for x in range(len(params['optim_conf']['def_total_hours']), params['optim_conf']['num_def_loads']):
Expand Down

0 comments on commit 1109aec

Please sign in to comment.