Skip to content

Commit

Permalink
Merge pull request #405 from davidusb-geek/davidusb-geek/dev/pv_insta…
Browse files Browse the repository at this point in the history
…ll_optional

Make PV system optional
  • Loading branch information
davidusb-geek authored Dec 29, 2024
2 parents 99d08cc + 9ff95f0 commit b46d6fa
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 16 deletions.
40 changes: 26 additions & 14 deletions src/emhass/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,18 @@ def set_input_data_dict(
P_PV_forecast, P_load_forecast, df_input_data_dayahead = None, None, None
elif set_type == "dayahead-optim":
# Get PV and load forecasts
df_weather = fcst.get_weather_forecast(
method=optim_conf["weather_forecast_method"]
)
if isinstance(df_weather, bool) and not df_weather:
return False
P_PV_forecast = fcst.get_power_from_weather(df_weather)
if (
optim_conf["set_use_pv"]
or optim_conf.get("weather_forecast_method", None) == "list"
):
df_weather = fcst.get_weather_forecast(
method=optim_conf["weather_forecast_method"]
)
if isinstance(df_weather, bool) and not df_weather:
return False
P_PV_forecast = fcst.get_power_from_weather(df_weather)
else:
P_PV_forecast = pd.Series(0, index=fcst.forecast_dates)
P_load_forecast = fcst.get_load_forecast(
method=optim_conf["load_forecast_method"]
)
Expand Down Expand Up @@ -258,14 +264,20 @@ def set_input_data_dict(
return False
df_input_data = rh.df_final.copy()
# Get PV and load forecasts
df_weather = fcst.get_weather_forecast(
method=optim_conf["weather_forecast_method"]
)
if isinstance(df_weather, bool) and not df_weather:
return False
P_PV_forecast = fcst.get_power_from_weather(
df_weather, set_mix_forecast=True, df_now=df_input_data
)
if (
optim_conf["set_use_pv"]
or optim_conf.get("weather_forecast_method", None) == "list"
):
df_weather = fcst.get_weather_forecast(
method=optim_conf["weather_forecast_method"]
)
if isinstance(df_weather, bool) and not df_weather:
return False
P_PV_forecast = fcst.get_power_from_weather(
df_weather, set_mix_forecast=True, df_now=df_input_data
)
else:
P_PV_forecast = pd.Series(0, index=fcst.forecast_dates)
P_load_forecast = fcst.get_load_forecast(
method=optim_conf["load_forecast_method"],
set_mix_forecast=True,
Expand Down
1 change: 1 addition & 0 deletions src/emhass/data/associations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ params_secrets,lon,Longitude
params_secrets,alt,Altitude
optim_conf,costfun,costfun
optim_conf,logging_level,logging_level
optim_conf,set_use_pv,set_use_pv
optim_conf,set_use_battery,set_use_battery
optim_conf,num_def_loads,number_of_deferrable_loads
optim_conf,P_deferrable_nom,nominal_power_of_deferrable_loads,list_nominal_power_of_deferrable_loads
Expand Down
1 change: 1 addition & 0 deletions src/emhass/data/config_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"photovoltaic_production_sell_price": 0.1419,
"maximum_power_from_grid": 9000,
"maximum_power_to_grid": 9000,
"set_use_pv": false,
"pv_module_model": [
"CSUN_Eurasia_Energy_Systems_Industry_and_Trade_CSUN295_60M"
],
Expand Down
4 changes: 4 additions & 0 deletions src/emhass/static/configuration_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ <h4>Deferrable Loads</h4>
<div id="Solar System (PV)" class="section-card">
<div class="section-card-header">
<h4>Solar System (PV)</h4>
<label class="switch"> <!-- switch connected to set_use_pv -->
<input id="set_use_pv" type="checkbox">
<span class="slider"></span>
</label>
</div>
<div class="section-body"> </div> <!-- parameters will get generated here -->
</div>
Expand Down
17 changes: 15 additions & 2 deletions src/emhass/static/configuration_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function loadConfigurationListView(param_definitions, config, list_html) {
}

//list parameters used in the section headers
header_input_list = ["set_use_battery", "number_of_deferrable_loads"];
header_input_list = ["set_use_battery", "set_use_pv", "number_of_deferrable_loads"];

//get the main container and append list template html
document.getElementById("configuration-container").innerHTML = list_html;
Expand Down Expand Up @@ -265,7 +265,7 @@ function buildParamContainers(
});

//check initial checkbox state, check "value" of input and match to "checked" value
let checkbox = document.querySelectorAll("input[type='checkbox']");
let checkbox = SectionContainer.querySelectorAll("input[type='checkbox']");
checkbox.forEach(function (answer) {
let value = answer.value === "true";
answer.checked = value;
Expand Down Expand Up @@ -559,6 +559,19 @@ function headerElement(element, param_definitions, config) {
}
break;

//if set_use_pv, add or remove PV section (inc. related params)
case "set_use_pv":
if (element.checked) {
param_container.innerHTML = "";
buildParamContainers("Solar System (PV)", param_definitions["Solar System (PV)"], config, [
"set_use_pv",
]);
element.checked = true;
} else {
param_container.innerHTML = "";
}
break;

//if number_of_deferrable_loads, the number of inputs in the "Deferrable Loads" section should add up to number_of_deferrable_loads value in header
case "number_of_deferrable_loads":
//get a list of param in section
Expand Down
6 changes: 6 additions & 0 deletions src/emhass/static/data/param_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@
}
},
"Solar System (PV)": {
"set_use_pv": {
"friendly_name": "Enable PV system",
"Description": "Set to True if we should consider an solar PV system. Defaults to False",
"input": "boolean",
"default_value": false
},
"pv_module_model": {
"friendly_name": "PV module model name",
"Description": "The PV module model. This parameter can be a list of items to enable the simulation of mixed orientation systems.",
Expand Down

0 comments on commit b46d6fa

Please sign in to comment.