Skip to content

Commit 7fc0444

Browse files
committed
Improve logic
1 parent 03e4a89 commit 7fc0444

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

plugwise/data.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,16 @@ def _add_or_update_notifications(
111111
if entity_id != self._gateway_id:
112112
return
113113

114-
if (self._is_thermostat or self.smile.type == "power") and "binary_sensors" not in entity:
115-
entity.update({"binary_sensors": {"plugwise_notification": bool(self._notifications)}})
116-
entity.update({"notifications": self._notifications})
117-
self._count += 2
118-
119-
if "plugwise_notification" in entity["binary_sensors"]:
120-
entity["binary_sensors"]["plugwise_notification"] = bool(self._notifications)
121-
entity["notifications"] = self._notifications
122-
self._count += 2
114+
if self._is_thermostat or self.smile.type == "power":
115+
if "plugwise_notification" not in entity:
116+
entity["binary_sensors"].update({"plugwise_notification": bool(self._notifications)})
117+
entity.update({"notifications": self._notifications})
118+
self._count += 2
119+
120+
else:
121+
entity["binary_sensors"]["plugwise_notification"] = bool(self._notifications)
122+
entity["notifications"] = self._notifications
123+
self._count += 2
123124

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

0 commit comments

Comments
 (0)