Skip to content

Commit 86a33b5

Browse files
committed
Use negative as suggested
1 parent 700073e commit 86a33b5

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

plugwise/helper.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -807,22 +807,24 @@ def _rank_thermostat(
807807
Rank the thermostat based on entity-thermostat-type: primary or secondary.
808808
There can be several primary and secondary thermostats per location.
809809
"""
810-
if (appl_class := entity["dev_class"]) in thermo_matching:
811-
# Pre-elect new primary
812-
if thermo_matching[appl_class] == location["primary_prio"]:
813-
location["primary"].append(entity_id)
814-
elif (thermo_rank := thermo_matching[appl_class]) > location[
815-
"primary_prio"
816-
]:
817-
location["primary_prio"] = thermo_rank
818-
# Demote former primary
819-
if tl_primary := location["primary"]:
820-
location["secondary"] += tl_primary
821-
location["primary"] = []
822-
# Crown primary
823-
location["primary"].append(entity_id)
824-
else:
825-
location["secondary"].append(entity_id)
810+
if (appl_class := entity["dev_class"]) not in thermo_matching:
811+
return None
812+
813+
# Pre-elect new primary
814+
if thermo_matching[appl_class] == location["primary_prio"]:
815+
location["primary"].append(entity_id)
816+
elif (thermo_rank := thermo_matching[appl_class]) > location[
817+
"primary_prio"
818+
]:
819+
location["primary_prio"] = thermo_rank
820+
# Demote former primary
821+
if tl_primary := location["primary"]:
822+
location["secondary"] += tl_primary
823+
location["primary"] = []
824+
# Crown primary
825+
location["primary"].append(entity_id)
826+
else:
827+
location["secondary"].append(entity_id)
826828

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

0 commit comments

Comments
 (0)