diff --git a/custom_components/waterguru/sensor.py b/custom_components/waterguru/sensor.py index e4e3526..7fa1972 100644 --- a/custom_components/waterguru/sensor.py +++ b/custom_components/waterguru/sensor.py @@ -222,8 +222,11 @@ def extra_state_attributes(self) -> dict[str, str] | None: WaterGuruEntityAttributes.STATUS_COLOR: m.get("status"), } - if m.get("alerts") is not None and len(m.get("alerts")) > 0 and m.get("alerts")[0].get("advice") is not None: - a[WaterGuruEntityAttributes.ADVICE] = m.get("alerts")[0].get("advice").get("action").get("summary") + alerts = m.get("alerts") + if alerts: + advice = alerts[0].get("advice", {}).get("action", {}).get("summary") + if advice is not None: + a[WaterGuruEntityAttributes.ADVICE] = advice return a