Skip to content

Commit b10bb85

Browse files
committed
Fix SonarCloud reports
1 parent 84af2b2 commit b10bb85

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

plugwise/common.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,7 @@ def _get_groups(self) -> None:
212212
group_type = group.find("type").text
213213
group_appliances = group.findall("appliances/appliance")
214214
for item in group_appliances:
215-
# Check if members are not orphaned - stretch
216-
if item.get("id") in self.gw_entities:
217-
members.append(item.get("id"))
215+
self._add_member(item)
218216

219217
if group_type in GROUP_TYPES and members and group_id:
220218
self.gw_entities[group_id] = {
@@ -228,12 +226,17 @@ def _get_groups(self) -> None:
228226

229227
removed = list(set(self._existing_groups) - set(self._new_groups))
230228
if self._existing_groups and removed:
231-
for group in removed:
232-
self.gw_entities.pop(group)
229+
for group_id in removed:
230+
self.gw_entities.pop(group_id)
233231

234232
self._existing_groups = self._new_groups
235233
self._new_groups = []
236234

235+
def _add_member(element: etree.Element, members: list[str]) -> None:
236+
"""Check and add member to list."""
237+
if element.attrib["id"] in self.gw_entities:
238+
members.append(item.attrib["id"])
239+
237240
def _get_lock_state(
238241
self, xml: etree.Element, data: GwEntityData, stretch_v2: bool = False
239242
) -> None:

plugwise/smile.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,10 @@ def get_all_gateway_entities(self) -> None:
109109
Collect and add switching- and/or pump-group entities.
110110
Finally, collect the data and states for each entity.
111111
"""
112-
if self._get_appliances():
113-
if self._is_thermostat:
114-
self.therms_with_offset_func = (
115-
self._get_appliances_with_offset_functionality()
116-
)
112+
if self._get_appliances() and self._is_thermostat:
113+
self.therms_with_offset_func = (
114+
self._get_appliances_with_offset_functionality()
115+
)
117116

118117
self._get_groups()
119118
self._all_entity_data()

0 commit comments

Comments
 (0)