Skip to content

Commit 4d20836

Browse files
committed
Avoid growing of primary and secondary thermostat lists
1 parent ccb9fba commit 4d20836

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

plugwise/helper.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -884,18 +884,24 @@ def _rank_thermostat(
884884
return None
885885

886886
# Pre-elect new primary
887-
if thermo_matching[appl_class] == location["primary_prio"]:
887+
if (
888+
thermo_matching[appl_class] == location["primary_prio"]
889+
and entity_id not in location["primary"]
890+
):
888891
location["primary"].append(entity_id)
889892
elif (thermo_rank := thermo_matching[appl_class]) > location["primary_prio"]:
890893
location["primary_prio"] = thermo_rank
891894
# Demote former primary
892895
if tl_primary := location["primary"]:
893-
location["secondary"] += tl_primary
896+
for item in tl_primary:
897+
if item not in location["secondary"]:
898+
location["secondary"].append(item)
894899
location["primary"] = []
895900
# Crown primary
896-
location["primary"].append(entity_id)
897-
else:
898-
location["secondary"].append(entity_id)
901+
if entity_id not in location["primary"]:
902+
location["primary"].append(entity_id)
903+
elif entity_id not in location["secondary"]:
904+
location["secondary"].append(entity_id)
899905

900906
def _control_state(self, data: GwEntityData) -> str | bool:
901907
"""Helper-function for _get_location_data().

0 commit comments

Comments
 (0)