Skip to content

Commit 981b944

Browse files
committed
Rework _add_or_update_notifications()
1 parent a76377e commit 981b944

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

plugwise/data.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,18 @@ def _detect_low_batteries(self) -> list[str]:
106106
def _add_or_update_notifications(
107107
self, entity_id: str, entity: GwEntityData
108108
) -> None:
109-
"""Helper-function adding or updating the Plugwise notifications."""
110-
if (
111-
entity_id == self._gateway_id
112-
and (self._is_thermostat or self.smile.type == "power")
113-
) or (
114-
"binary_sensors" in entity
115-
and "plugwise_notification" in entity["binary_sensors"]
116-
):
117-
entity["binary_sensors"]["plugwise_notification"] = bool(
118-
self._notifications
119-
)
120-
entity["notifications"] = self._notifications
121-
self._count += 2
109+
"""Helper-function adding or updating the Plugwise notifications to the gateway."""
110+
111+
if entity_id != self._gateway_id:
112+
return # pragma: no cover
113+
114+
if self._is_thermostat or self.smile.type == "power":
115+
if "plugwise_notification" not in entity["binary_sensors"]:
116+
entity["binary_sensors"].update(
117+
{"plugwise_notification": bool(self._notifications)}
118+
)
119+
entity.update({"notifications": self._notifications})
120+
self._count += 2
122121

123122
def _update_for_cooling(self, entity: GwEntityData) -> None:
124123
"""Helper-function for adding/updating various cooling-related values."""

0 commit comments

Comments
 (0)