Skip to content

Commit d987717

Browse files
committed
Implement improvement suggestion
1 parent bbf3161 commit d987717

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

plugwise/legacy/helper.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,14 @@ def _all_appliances(self) -> None:
139139
self._reorder_devices()
140140

141141
def _reorder_devices(self) -> None:
142-
"""Place the gateway and optional heater_central devices as 1st and 2nd."""
142+
"""Place the gateway and optional heater_central devices as 1st and 2nd."""
143+
reordered = {}
143144
for dev_class in PRIORITY_DEVICE_CLASSES:
144145
for entity_id, entity in dict(self.gw_entities).items():
145146
if entity["dev_class"] == dev_class:
146-
tmp_entity = entity
147-
self.gw_entities.pop(entity_id)
148-
cleared_dict = self.gw_entities
149-
add_to_front = {entity_id: tmp_entity}
150-
self.gw_entities = {**add_to_front, **cleared_dict}
147+
reordered[entity_id] = self.gw_entities.pop(entity_id)
151148
break
149+
self.gw_entities = {**reordered, **self.gw_entities}
152150

153151
def _all_locations(self) -> None:
154152
"""Collect all locations."""

0 commit comments

Comments
 (0)