Skip to content

Commit 0cd1148

Browse files
committed
Fix SonarCloud reports
1 parent 0ea3bb3 commit 0cd1148

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
@@ -213,9 +213,7 @@ def _get_groups(self) -> None:
213213
group_type = group.find("type").text
214214
group_appliances = group.findall("appliances/appliance")
215215
for item in group_appliances:
216-
# Check if members are not orphaned - stretch
217-
if item.attrib["id"] in self.gw_entities:
218-
members.append(item.attrib["id"])
216+
self._add_member(item)
219217

220218
if group_type in GROUP_TYPES and members:
221219
self.gw_entities[group_id] = {
@@ -229,12 +227,17 @@ def _get_groups(self) -> None:
229227

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

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

236+
def _add_member(element: etree.Element, members: list[str]) -> None:
237+
"""Check and add member to list."""
238+
if element.attrib["id"] in self.gw_entities:
239+
members.append(item.attrib["id"])
240+
238241
def _get_lock_state(
239242
self, xml: etree.Element, data: GwEntityData, stretch_v2: bool = False
240243
) -> 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._scan_thermostats()
119118

0 commit comments

Comments
 (0)