@@ -612,8 +612,11 @@ def _all_appliances(self) -> None:
612612 appl .location = None
613613 if (appl_loc := appliance .find ("location" )) is not None :
614614 appl .location = appl_loc .attrib ["id" ]
615- # Provide a home_location for legacy_anna
616- elif self ._smile_legacy and self .smile_type == "thermostat" :
615+ # Provide a home_location for legacy_anna, don't assign the _home_location
616+ # to thermostat-devices without a location, they are not active
617+ elif (
618+ self ._smile_legacy and self .smile_type == "thermostat"
619+ ) or appl .pwclass not in THERMOSTAT_CLASSES :
617620 appl .location = self ._home_location
618621
619622 appl .dev_id = appliance .attrib ["id" ]
@@ -668,6 +671,9 @@ def _match_locations(self) -> dict[str, ThermoLoc]:
668671 for location_id , location_details in self ._loc_data .items ():
669672 for _ , appliance_details in self ._appl_data .items ():
670673 if appliance_details ["location" ] == location_id :
674+ location_details .update (
675+ {"master" : None , "master_prio" : 0 , "slaves" : set ()}
676+ )
671677 matched_locations [location_id ] = location_details
672678
673679 return matched_locations
@@ -869,9 +875,7 @@ def _rank_thermostat(
869875 Rank the thermostat based on appliance_details: master or slave."""
870876 appl_class = appliance_details ["dev_class" ]
871877 appl_d_loc = appliance_details ["location" ]
872- if (
873- loc_id == appl_d_loc or (self ._smile_legacy and not appl_d_loc )
874- ) and appl_class in thermo_matching :
878+ if loc_id == appl_d_loc and appl_class in thermo_matching :
875879
876880 # Pre-elect new master
877881 if thermo_matching [appl_class ] > self ._thermo_locs [loc_id ]["master_prio" ]:
@@ -888,7 +892,8 @@ def _rank_thermostat(
888892
889893 def _scan_thermostats (self ) -> None :
890894 """Helper-function for smile.py: get_all_devices().
891- Update locations with thermostat ranking results.
895+ Update locations with thermostat ranking results and use
896+ the result to update the device_class of slave thermostats.
892897 """
893898 if self .smile_type != "thermostat" :
894899 pass
@@ -902,22 +907,16 @@ def _scan_thermostats(self) -> None:
902907 "thermostatic_radiator_valve" : 1 ,
903908 }
904909
905- for loc_id , location_details in self ._thermo_locs .items ():
906- self ._thermo_locs [loc_id ] = location_details
907-
908- if loc_id != self ._home_location :
909- self ._thermo_locs [loc_id ].update (
910- {"master" : None , "master_prio" : 0 , "slaves" : set ()}
911- )
912- elif self ._smile_legacy :
913- self ._thermo_locs [loc_id ].update (
914- {"master" : None , "master_prio" : 0 , "slaves" : set ()}
915- )
910+ for loc_id in self ._thermo_locs :
911+ for appl_id , details in self ._appl_data .items ():
912+ self ._rank_thermostat (thermo_matching , loc_id , appl_id , details )
916913
917- for appliance_id , appliance_details in self ._appl_data .items ():
918- self ._rank_thermostat (
919- thermo_matching , loc_id , appliance_id , appliance_details
920- )
914+ # Update slave thermostat class where needed
915+ for appl_id , details in self ._appl_data .items ():
916+ if (loc_id := details ["location" ]) in self ._thermo_locs :
917+ tl_loc_id = self ._thermo_locs [loc_id ]
918+ if "slaves" in tl_loc_id and appl_id in tl_loc_id ["slaves" ]:
919+ details ["dev_class" ] = "thermo_sensor"
921920
922921 def _thermostat_uri_legacy (self ) -> str :
923922 """Helper-function for _thermostat_uri().
0 commit comments