Skip to content

Commit 02aca5f

Browse files
committed
Optimize _get_groups(), fix group_id
1 parent 8bdae45 commit 02aca5f

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

plugwise/common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ def _entity_switching_group(self, entity: GwEntityData) -> None:
188188
entity["switches"]["relay"] = counter != 0
189189
self._count += 1
190190

191-
def _get_groups(self) -> dict[str, GwEntityData]:
191+
def _get_groups(self) -> None:
192192
"""Helper-function for smile.py: get_all_gateway_entities().
193193
194194
Collect switching-, pumping- or report-group info.
195195
"""
196196
groups: dict[str, GwEntityData] = {}
197197
# P1 and Anna don't have groups
198198
if self.smile.type == "power" or self.check_name(ANNA):
199-
return groups
199+
return
200200

201201
for group in self._domain_objects.findall("./group"):
202202
members: list[str] = []
@@ -210,7 +210,7 @@ def _get_groups(self) -> dict[str, GwEntityData]:
210210
members.append(item.get("id"))
211211

212212
if group_type in GROUP_TYPES and members:
213-
groups[group_id] = {
213+
self.gw_entities[group_id] = {
214214
"dev_class": group_type,
215215
"model": "Group",
216216
"name": group_name,
@@ -219,8 +219,6 @@ def _get_groups(self) -> dict[str, GwEntityData]:
219219
}
220220
self._count += 5
221221

222-
return groups
223-
224222
def _get_lock_state(
225223
self, xml: etree.Element, data: GwEntityData, stretch_v2: bool = False
226224
) -> None:

plugwise/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,12 @@ def _get_measurement_data(self, entity_id: str, entity: GwEntityData) -> None:
393393
def _collect_group_sensors(
394394
self,
395395
data: GwEntityData,
396-
entity_id: str,
396+
group_id: str,
397397
measurements: dict[str, UOM],
398398
) -> None:
399399
"""Collect group sensors."""
400400
if (
401-
group := self._domain_objects.find(f'./group[@id="{entity_id}"]')
401+
group := self._domain_objects.find(f'./group[@id="{group_id}"]')
402402
) is not None:
403403
for measurement, attrs in measurements.items():
404404
locator = f'.//logs/point_log[type="{measurement}"]/period/measurement'

plugwise/legacy/smile.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ def get_all_gateway_entities(self) -> None:
8282
Finally, collect the data and states for each entity.
8383
"""
8484
self._all_appliances()
85-
if group_data := self._get_groups():
86-
self.gw_entities.update(group_data)
87-
85+
self._get_groups()
8886
self._all_entity_data()
8987

9088
async def async_update(self) -> dict[str, GwEntityData]:

plugwise/smile.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ def get_all_gateway_entities(self) -> None:
113113
)
114114
self._scan_thermostats()
115115

116-
if group_data := self._get_groups():
117-
self.gw_entities.update(group_data)
118-
116+
self._get_groups()
119117
self._all_entity_data()
120118

121119
async def async_update(self) -> dict[str, GwEntityData]:

0 commit comments

Comments
 (0)