Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configuration page init pv switch #407

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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