diff --git a/custom_components/ideenergy/manifest.json b/custom_components/ideenergy/manifest.json index e38d52a..5a74359 100644 --- a/custom_components/ideenergy/manifest.json +++ b/custom_components/ideenergy/manifest.json @@ -12,5 +12,5 @@ "ideenergy==1.0.0", "homeassistant-historical-sensor==1.0.1" ], - "version": "2.0.0" + "version": "2.0.1" } \ No newline at end of file diff --git a/custom_components/ideenergy/sensor.py b/custom_components/ideenergy/sensor.py index 7e4f84d..19672b2 100644 --- a/custom_components/ideenergy/sensor.py +++ b/custom_components/ideenergy/sensor.py @@ -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