Skip to content

Commit 2a50706

Browse files
committed
Use different approach for collection zone-data too
1 parent f544a71 commit 2a50706

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

plugwise/data.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def _update_zones(self) -> None:
4545
Collect data for each zone/location and add to self._zones.
4646
"""
4747
for location_id, zone in self._zones.items():
48-
data = self._get_location_data(location_id)
49-
zone.update(data)
48+
self._get_location_data(location_id, zone)
5049

5150
def _update_gw_entities(self) -> None:
5251
"""Helper-function for _all_entities_data() and async_update().
@@ -155,33 +154,30 @@ def _update_for_cooling(self, entity: GwEntityData) -> None:
155154
3 # add 4 total, remove 1, count the conditional remove separately
156155
)
157156

158-
def _get_location_data(self, loc_id: str) -> GwEntityData:
157+
def _get_location_data(self, loc_id: str, zone: GwEntityData) -> None:
159158
"""Helper-function for _all_entity_data() and async_update().
160159
161160
Provide entity-data, based on Location ID (= loc_id).
162161
"""
163-
zone = self._zones[loc_id]
164-
data = self._get_zone_data(loc_id)
165-
self._regulation_control(data)
162+
self._get_zone_data(loc_id, zone)
163+
self._regulation_control(zone)
166164

167-
data["control_state"] = "idle"
165+
zone["control_state"] = "idle"
168166
self._count += 1
169-
if (ctrl_state := self._control_state(data)) and ctrl_state in (
167+
if (ctrl_state := self._control_state(zone)) and ctrl_state in (
170168
"cooling",
171169
"heating",
172170
"preheating",
173171
):
174-
data["control_state"] = str(ctrl_state)
172+
zone["control_state"] = str(ctrl_state)
175173

176-
if "setpoint" in data["sensors"]:
177-
data["sensors"].pop("setpoint") # remove, only used in _control_state()
174+
if "setpoint" in zone["sensors"]:
175+
zone["sensors"].pop("setpoint") # remove, only used in _control_state()
178176
self._count -= 1
179177

180178
# Thermostat data (presets, temperatures etc)
181179
self._climate_data(loc_id, zone)
182180

183-
return data
184-
185181
def _get_entity_data(self, entity_id: str, entity: GwEntityData) -> None:
186182
"""Helper-function for _update_gw_entities() and async_update().
187183

plugwise/helper.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,20 @@ def _get_appliances_with_offset_functionality(self) -> list[str]:
305305

306306
return therm_list
307307

308-
def _get_zone_data(self, loc_id: str) -> GwEntityData:
308+
def _get_zone_data(self, loc_id: str, zone: GwEntityData) -> None:
309309
"""Helper-function for smile.py: _get_entity_data().
310310
311-
Collect the location-data based on location id.
311+
Collect the location/zone-data based on location id.
312312
"""
313313
data: GwEntityData = {"sensors": {}}
314-
zone = self._zones[loc_id]
315314
measurements = ZONE_MEASUREMENTS
316315
if (
317316
location := self._domain_objects.find(f'./location[@id="{loc_id}"]')
318317
) is not None:
319318
self._appliance_measurements(location, data, measurements)
320319
self._get_actuator_functionalities(location, zone, data)
321320

322-
return data
321+
zone.update(data)
323322

324323
def _get_measurement_data(self, entity_id: str, entity: GwEntityData) -> None:
325324
"""Helper-function for smile.py: _get_entity_data().

0 commit comments

Comments
 (0)