Skip to content

Commit

Permalink
Merge pull request #407 from GeoDerp/davidusb-geek/dev/pv_install_opt…
Browse files Browse the repository at this point in the history
…ional

configuration page init pv switch
  • Loading branch information
davidusb-geek authored Dec 29, 2024
2 parents 7d50e4b + aeab3ef commit 9ff95f0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/emhass/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ 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
if optim_conf['set_use_pv']:
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"]
)
Expand Down Expand Up @@ -244,7 +247,10 @@ def set_input_data_dict(
return False
df_input_data = rh.df_final.copy()
# Get PV and load forecasts
if optim_conf['set_use_pv']:
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"]
)
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

0 comments on commit 9ff95f0

Please sign in to comment.