Skip to content

Commit 95642c6

Browse files
committed
Fix/guard/add count
1 parent 7b3c87d commit 95642c6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plugwise/data.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ def _update_for_cooling(self, entity: GwEntityData) -> None:
144144
entity["thermostat"] = temp_dict
145145
if "setpoint" in sensors:
146146
sensors.pop("setpoint")
147+
self._count -= 1
147148
sensors["setpoint_low"] = temp_dict["setpoint_low"]
148149
sensors["setpoint_high"] = temp_dict["setpoint_high"]
149-
self._count += 2 # add 4, remove 2
150+
self._count += 3 # add 4, remove 1
150151

151152
def _get_location_data(self, loc_id: str) -> GwEntityData:
152153
"""Helper-function for _all_entity_data() and async_update().
@@ -164,8 +165,9 @@ def _get_location_data(self, loc_id: str) -> GwEntityData:
164165
):
165166
data["control_state"] = str(ctrl_state)
166167

167-
data["sensors"].pop("setpoint") # remove, only used in _control_state()
168-
self._count -= 1
168+
if "setpoint" in data["sensors"]:
169+
data["sensors"].pop("setpoint") # remove, only used in _control_state()
170+
self._count -= 1
169171

170172
# Thermostat data (presets, temperatures etc)
171173
self._climate_data(loc_id, zone, data)
@@ -238,6 +240,7 @@ def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
238240
and self._cooling_present
239241
):
240242
data["binary_sensors"]["cooling_enabled"] = self._cooling_enabled
243+
self._count += 1
241244

242245
# Show the allowed regulation_modes and gateway_modes
243246
if entity["dev_class"] == "gateway":

0 commit comments

Comments
 (0)