Skip to content

Commit 28408bf

Browse files
committed
Leave for-loops when done, use constant
1 parent b2aa539 commit 28408bf

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

plugwise/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ async def _smile_detect_legacy(
303303
locator = f"./{network}/mac"
304304
if (net_locator := system.find(locator)) is not None:
305305
self.smile_mac_address = net_locator.text
306+
break
306307
# P1 legacy:
307308
elif dsmrmain is not None:
308309
status = await self._request(STATUS)

plugwise/data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def _update_gw_entities(self) -> None:
6969
if entity_id == self._gateway_id:
7070
mac_list = self._detect_low_batteries()
7171
self._add_or_update_notifications(entity_id, entity, data)
72+
break # one gateway present
7273

7374
entity.update(data)
7475
is_battery_low = (
@@ -228,6 +229,7 @@ def _check_availability(
228229
for msg in item.values():
229230
if message in msg:
230231
data["available"] = False
232+
break
231233

232234
def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
233235
"""Helper-function for _get_entity_data().
@@ -334,11 +336,13 @@ def _get_schedule_states_with_off(
334336
loc_schedule_states[schedule] = "off"
335337
if schedule == selected and data["climate_mode"] == "auto":
336338
loc_schedule_states[schedule] = "on"
339+
337340
self._schedule_old_states[location] = loc_schedule_states
338341

339342
all_off = True
340343
for state in self._schedule_old_states[location].values():
341344
if state == "on":
342345
all_off = False
346+
343347
if all_off:
344348
data["select_schedule"] = OFF

plugwise/helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def _sort_gw_entities(self) -> None:
195195
other_entities = self.gw_entities
196196
priority_entities = {entity_id: priority_entity}
197197
self.gw_entities = {**priority_entities, **other_entities}
198+
break
198199

199200
def _all_locations(self) -> None:
200201
"""Collect all locations."""

plugwise/legacy/helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
LIMITS,
2323
NONE,
2424
OFF,
25+
PRIORITY_DEVICE_CLASSES ,
2526
P1_LEGACY_MEASUREMENTS,
2627
TEMP_CELSIUS,
2728
THERMOSTAT_CLASSES,
@@ -130,14 +131,15 @@ def _all_appliances(self) -> None:
130131
self._create_gw_entities(appl)
131132

132133
# Place the gateway and optional heater_central devices as 1st and 2nd
133-
for dev_class in ("heater_central", "gateway"):
134+
for dev_class in PRIORITY_DEVICE_CLASSES :
134135
for entity_id, entity in dict(self.gw_entities).items():
135136
if entity["dev_class"] == dev_class:
136137
tmp_entity = entity
137138
self.gw_entities.pop(entity_id)
138139
cleared_dict = self.gw_entities
139140
add_to_front = {entity_id: tmp_entity}
140141
self.gw_entities = {**add_to_front, **cleared_dict}
142+
break
141143

142144
def _all_locations(self) -> None:
143145
"""Collect all locations."""

0 commit comments

Comments
 (0)