Skip to content

Commit

Permalink
Merge pull request #335 from werdnum/freq
Browse files Browse the repository at this point in the history
Only automatically set the DateTimeIndex frequency if no "freq" is set in retrieve_hass_conf
  • Loading branch information
davidusb-geek authored Sep 8, 2024
2 parents 24ab7b5 + 20fe477 commit 6df5d20
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/emhass/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ def set_input_data_dict(emhass_conf: dict, costfun: str,
df_input_data_dayahead = pd.DataFrame(np.transpose(np.vstack(
[P_PV_forecast.values, P_load_forecast.values])), index=P_PV_forecast.index,
columns=["P_PV_forecast", "P_load_forecast"])
df_input_data_dayahead = utils.set_df_index_freq(df_input_data_dayahead)
if "freq" in retrieve_hass_conf and retrieve_hass_conf["freq"]:
freq = pd.to_timedelta(retrieve_hass_conf["freq"], "minute")
df_input_data_dayahead = df_input_data_dayahead.asfreq(freq)
else:
df_input_data_dayahead = utils.set_df_index_freq(df_input_data_dayahead)
params = json.loads(params)
if ("prediction_horizon" in params["passed_data"] and params["passed_data"]["prediction_horizon"] is not None):
prediction_horizon = params["passed_data"]["prediction_horizon"]
Expand Down Expand Up @@ -155,7 +159,11 @@ def set_input_data_dict(emhass_conf: dict, costfun: str,
"Unable to get sensor power photovoltaics, or sensor power load no var loads. Check HA sensors and their daily data")
return False
df_input_data_dayahead = pd.concat([P_PV_forecast, P_load_forecast], axis=1)
df_input_data_dayahead = utils.set_df_index_freq(df_input_data_dayahead)
if "freq" in retrieve_hass_conf and retrieve_hass_conf["freq"]:
freq = pd.to_timedelta(retrieve_hass_conf["freq"], "minute")
df_input_data_dayahead = df_input_data_dayahead.asfreq(freq)
else:
df_input_data_dayahead = utils.set_df_index_freq(df_input_data_dayahead)
df_input_data_dayahead.columns = ["P_PV_forecast", "P_load_forecast"]
params = json.loads(params)
if ("prediction_horizon" in params["passed_data"] and params["passed_data"]["prediction_horizon"] is not None):
Expand Down

0 comments on commit 6df5d20

Please sign in to comment.