Skip to content

Commit

Permalink
Fix incorrect statistics calculation
Browse files Browse the repository at this point in the history
See #42
  • Loading branch information
ldotlopez committed Mar 16, 2023
1 parent 288ab92 commit 78df977
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/ideenergy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ async def async_calculate_statistic_data(
) -> List[StatisticData]:

if latest:
cutoff = dtutil.utc_from_timestamp(latest["end"])
accumulated = latest["sum"] or 0
hist_states = [x for x in hist_states if x.when >= latest["end"]]
hist_states = [x for x in hist_states if x.dt >= cutoff]

else:
accumulated = 0
Expand Down

0 comments on commit 78df977

Please sign in to comment.