Skip to content

Commit fb23596

Browse files
committed
Add _collect_group_sensors() function
1 parent 7ce779a commit fb23596

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

plugwise/common.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,10 @@ def _get_groups(self) -> dict[str, GwEntityData]:
220220
"model": "Group",
221221
"name": group_name,
222222
"members": members,
223-
"sensors": group_sensors,
224223
"vendor": "Plugwise",
225224
}
226225
self._count += 5
227226

228-
for measurement, attrs in GROUP_MEASUREMENTS.items():
229-
locator = f'logs/point_log[type="{measurement}"]/period/measurement'
230-
if (group_meas_loc := group.find(locator)) is not None:
231-
common_match_cases(measurement, attrs, group_meas_loc, groups[group_id])
232-
self._count += 1
233-
234-
235-
LOGGER.debug("HOI groups: %s", groups)
236227
return groups
237228

238229
def _get_lock_state(

plugwise/helper.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
DHW_SETPOINT,
2222
DOMAIN_OBJECTS,
2323
ENERGY_WATT_HOUR,
24+
GROUP_MEASUREMENTS,
2425
HEATER_CENTRAL_MEASUREMENTS,
2526
LOCATIONS,
2627
LOGGER,
@@ -339,6 +340,11 @@ def _get_measurement_data(self, entity_id: str) -> GwEntityData:
339340
if smile_is_power and not self.smile.anna_p1:
340341
return data
341342

343+
# Get group data
344+
measurements = GROUP_MEASUREMENTS
345+
if "members" in entity:
346+
self._collect_group_sensors(data, entity, entity_id, measurements)
347+
342348
# Get non-P1 data from APPLIANCES
343349
measurements = DEVICE_MEASUREMENTS
344350
if self._is_thermostat and entity_id == self.heater_id:
@@ -370,6 +376,27 @@ def _get_measurement_data(self, entity_id: str) -> GwEntityData:
370376

371377
return data
372378

379+
def _collect_group_sensors(
380+
self,
381+
data: GwEntityData,
382+
entity: GwEntityData,
383+
entity_id: str,
384+
measurements: dict[str, DATA | UOM],
385+
) -> None:
386+
"""Collect group sensors."""
387+
if (
388+
group := self._domain_objects.find(f'./group[@id="{entity_id}"]')
389+
) is None:
390+
return None
391+
392+
for measurement, attrs in measurements.items():
393+
locator = f'.//logs/point_log[type="{measurement}"]/period/measurement'
394+
if (group_meas_loc := group.find(locator)) is None:
395+
return
396+
397+
common_match_cases(measurement, attrs, group_meas_loc, data)
398+
self._count += 1
399+
373400
def _collect_appliance_data(
374401
self,
375402
data: GwEntityData,

0 commit comments

Comments
 (0)