Skip to content

Commit

Permalink
Merge pull request #96 from purcell-lab/patch-7
Browse files Browse the repository at this point in the history
Fix rounding for price & cost forecasts
  • Loading branch information
davidusb-geek authored Jul 13, 2023
2 parents 8d37f34 + 636296f commit 523c747
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/emhass/retrieve_hass.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ def get_attr_data_dict(data_df: pd.DataFrame, idx: int, entity_id: str,
list_df = copy.deepcopy(data_df).loc[data_df.index[idx]:].reset_index()
list_df.columns = ['timestamps', entity_id]
ts_list = [str(i) for i in list_df['timestamps'].tolist()]
vals_list = [str(np.round(i)) for i in list_df[entity_id].tolist()]
vals_list = [str(np.round(i,2)) for i in list_df[entity_id].tolist()]
forecast_list = []
for i, ts in enumerate(ts_list):
datum = {}
datum["date"] = ts
datum[entity_id.split('sensor.')[1]] = vals_list[i]
forecast_list.append(datum)
data = {
"state": str(state),
"state": "{:.2f}".format(state),
"attributes": {
"unit_of_measurement": unit_of_measurement,
"friendly_name": friendly_name,
Expand Down Expand Up @@ -307,7 +307,7 @@ def post_data(self, data_df: pd.DataFrame, idx: int, entity_id: str,
friendly_name, "scheduled_forecast", state)
else:
data = {
"state": str(state),
"state": "{:.2f}".format(state),
"attributes": {
"unit_of_measurement": unit_of_measurement,
"friendly_name": friendly_name
Expand Down

0 comments on commit 523c747

Please sign in to comment.