Skip to content

Commit

Permalink
Fix posible bug with none values in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
ldotlopez committed Jun 25, 2023
1 parent 084a622 commit b33c498
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/ideenergy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"ideenergy==1.0.0",
"homeassistant-historical-sensor==1.0.1"
],
"version": "2.0.0"
"version": "2.0.1"
}
6 changes: 5 additions & 1 deletion custom_components/ideenergy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ def hour_block_for_hist_state(hist_state: HistoricalState) -> datetime:
else:
return hist_state.dt.replace(minute=0, second=0, microsecond=0)

total_accumulated = latest["sum"] if latest else 0
if latest:
total_accumulated = latest.get("sum", 0) or 0
else:
total_accumulated = 0

ret = []

# Group historical states by hour block
Expand Down

0 comments on commit b33c498

Please sign in to comment.