Skip to content

Commit f9b5901

Browse files
committed
Improve avoid growing list
1 parent bd2d864 commit f9b5901

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

plugwise/helper.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,19 +884,17 @@ def _rank_thermostat(
884884
return None
885885

886886
# Pre-elect new primary
887-
if (
888-
thermo_matching[appl_class] == location["primary_prio"]
889-
and entity_id not in location["primary"]
890-
):
891-
location["primary"].append(entity_id)
887+
if thermo_matching[appl_class] == location["primary_prio"]:
888+
if entity_id not in location["primary"]:
889+
location["primary"].append(entity_id)
892890
elif (thermo_rank := thermo_matching[appl_class]) > location["primary_prio"]:
893891
location["primary_prio"] = thermo_rank
894892
# Demote former primary
895893
if tl_primary := location["primary"]:
896894
for item in tl_primary:
897895
if item not in location["secondary"]:
898896
location["secondary"].append(item)
899-
location["primary"] = []
897+
location["primary"].remove(item)
900898
# Crown primary
901899
if entity_id not in location["primary"]:
902900
location["primary"].append(entity_id)

0 commit comments

Comments
 (0)