99
1010from plugwise .constants import (
1111 ANNA ,
12+ GROUP_MEASUREMENTS ,
1213 GROUP_TYPES ,
1314 LOGGER ,
1415 NONE ,
2223from plugwise .util import (
2324 check_heater_central ,
2425 check_model ,
26+ common_match_cases ,
2527 format_measure ,
2628 get_vendor_name ,
2729 return_valid ,
@@ -201,6 +203,7 @@ def _get_groups(self) -> dict[str, GwEntityData]:
201203 return groups
202204
203205 for group in self ._domain_objects .findall ("./group" ):
206+ group_sensors = {}
204207 members : list [str ] = []
205208 group_id = group .attrib ["id" ]
206209 group_name = group .find ("name" ).text
@@ -211,16 +214,6 @@ def _get_groups(self) -> dict[str, GwEntityData]:
211214 if item .attrib ["id" ] in self .gw_entities :
212215 members .append (item .attrib ["id" ])
213216
214- group_sensors = {}
215- group_logs = group .findall ("logs/point_log" )
216- for log in group_logs :
217- LOGGER .debug ("HOI log: %s" , etree .tostring (log ))
218- log_type = log .find ("type" ).text
219- measurement = log .find ("period/measurement" )
220- if measurement is not None :
221- group_sensors [log_type ] = format_measure (measurement )
222- self ._count += 1
223-
224217 if group_type in GROUP_TYPES and members :
225218 groups [group_id ] = {
226219 "dev_class" : group_type ,
@@ -232,6 +225,11 @@ def _get_groups(self) -> dict[str, GwEntityData]:
232225 }
233226 self ._count += 5
234227
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+
235233 return groups
236234
237235 def _get_lock_state (
0 commit comments