@@ -570,15 +570,21 @@ def _all_appliances(self) -> None:
570570 # Legacy P1 has no more devices
571571 return
572572
573+ hc_count = 0
573574 for appliance in self ._appliances .findall ("./appliance" ):
574575 appl = Munch ()
575576 appl .pwclass = appliance .find ("type" ).text
576- # Skip thermostats that have this key, should be an orphaned device (Core #81712)
577+ # Count amount of heater_central's
578+ if appl .pwclass == "heater_central" :
579+ hc_count += 1
580+ # Mark heater_central and thermostat that don't have actuator_functionalities,
581+ # could be an orphaned device (Core #81712, #104433)
582+ appl .has_actuators = True
577583 if (
578- appl .pwclass == " thermostat"
584+ appl .pwclass in [ "heater_central" , " thermostat"]
579585 and appliance .find ("actuator_functionalities/" ) is None
580586 ):
581- continue
587+ appl . has_actuators = False
582588
583589 appl .location = None
584590 if (appl_loc := appliance .find ("location" )) is not None :
@@ -622,6 +628,7 @@ def _all_appliances(self) -> None:
622628 for key , value in {
623629 "firmware" : appl .firmware ,
624630 "hardware" : appl .hardware ,
631+ "has_actuators" : appl .has_actuators ,
625632 "location" : appl .location ,
626633 "mac_address" : appl .mac ,
627634 "model" : appl .model ,
@@ -634,6 +641,22 @@ def _all_appliances(self) -> None:
634641 self .gw_devices [appl .dev_id ][appl_key ] = value
635642 self ._count += 1
636643
644+ # Remove thermostat with empty actuator_functionalities (Core #81712), remove heater_central
645+ # with empty actuator_functionalities but only when there are more than one (Core #104433).
646+ for dev_id , device in dict (self .gw_devices ).items ():
647+ if device ["dev_class" ] == "thermostat" or (
648+ device ["dev_class" ] == "heater_central" and hc_count > 1
649+ ):
650+ if not self .gw_devices [dev_id ]["has_actuators" ]:
651+ self ._count -= len (self .gw_devices [dev_id ])
652+ self .gw_devices .pop (dev_id )
653+ else :
654+ self .gw_devices [dev_id ].pop ("has_actuators" )
655+ self ._count -= 1
656+ elif "has_actuators" in self .gw_devices [dev_id ]:
657+ self .gw_devices [dev_id ].pop ("has_actuators" )
658+ self ._count -= 1
659+
637660 # For non-legacy P1 collect the connected SmartMeter info
638661 if self .smile_type == "power" :
639662 self ._p1_smartmeter_info_finder (appl )
@@ -1521,15 +1544,12 @@ def _get_toggle_state(
15211544 Obtain the toggle state of a 'toggle' = switch.
15221545 """
15231546 if xml .find ("type" ).text == "heater_central" :
1524- locator = "./actuator_functionalities/toggle_functionality"
1525- if found := xml .findall (locator ):
1526- for item in found :
1527- if (toggle_type := item .find ("type" )) is not None :
1528- if toggle_type .text == toggle :
1529- data ["switches" ][name ] = item .find ("state" ).text == "on"
1530- self ._count += 1
1531- # Remove the cooling_enabled binary_sensor when the corresponding switch is present
1532- # Except for Elga
1533- if toggle == "cooling_enabled" and not self ._elga :
1534- data ["binary_sensors" ].pop ("cooling_enabled" )
1535- self ._count -= 1
1547+ locator = f"./actuator_functionalities/toggle_functionality[type='{ toggle } ']/state"
1548+ if (state := xml .find (locator )) is not None :
1549+ data ["switches" ][name ] = state .text == "on"
1550+ self ._count += 1
1551+ # Remove the cooling_enabled binary_sensor when the corresponding switch is present
1552+ # Except for Elga
1553+ if toggle == "cooling_enabled" and not self ._elga :
1554+ data ["binary_sensors" ].pop ("cooling_enabled" )
1555+ self ._count -= 1
0 commit comments