Skip to content

Commit d8ae204

Browse files
committed
Guard for missing thermostat data
1 parent c630812 commit d8ae204

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

plugwise/helper.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,11 @@ def _control_state(self, data: GwEntityData) -> str | bool:
820820
Represents the heating/cooling demand-state of the local primary thermostat.
821821
Note: heating or cooling can still be active when the setpoint has been reached.
822822
"""
823+
if (thermostat := data.get("thermostat")) is None:
824+
LOGGER.warning("Something wrong, incomplete thermostat data")
825+
return
823826

824-
if (ctrl_state := data["thermostat"].get("control_state")) is not None:
827+
if (ctrl_state := thermostat.get("control_state")) is not None:
825828
data["thermostat"].pop("control_state")
826829
self._count -= 1
827830
return ctrl_state
@@ -863,8 +866,11 @@ def _regulation_control(self, data: GwEntityData) -> None:
863866
864867
Adam: collect the thermostat regulation_control state of a location.
865868
"""
866-
LOGGER.debug("HOI data: %s", data)
867-
if (reg_control := data["thermostat"].get("regulation_control")) is not None:
869+
if (thermostat := data.get("thermostat")) is None:
870+
LOGGER.warning("Something wrong, incomplete thermostat data")
871+
return
872+
873+
if (reg_control := thermostat.get("regulation_control")) is not None:
868874
data["select_zone_profile"] = reg_control
869875
data["zone_profiles"] = ALLOWED_ZONE_PROFILES
870876
data["thermostat"].pop("regulation_control")

0 commit comments

Comments
 (0)