diff --git a/zha/application/platforms/binary_sensor/__init__.py b/zha/application/platforms/binary_sensor/__init__.py index 6173889d1..676cbd917 100644 --- a/zha/application/platforms/binary_sensor/__init__.py +++ b/zha/application/platforms/binary_sensor/__init__.py @@ -75,6 +75,7 @@ def __init__( self._cluster_handler = cluster_handlers[0] super().__init__(cluster_handlers, endpoint, device, **kwargs) self._state: bool = self.is_on + self.recompute_capabilities() def on_add(self) -> None: """Run when entity is added.""" @@ -247,16 +248,10 @@ class IASZone(BinarySensor): # TODO: split this sensor off into individual sensor classes per IASZone type - def __init__( - self, - cluster_handlers: list[ClusterHandler], - endpoint: Endpoint, - device: Device, - **kwargs, - ) -> None: - """Initialize the ZHA binary sensor.""" - cluster_handler = cluster_handlers[0] - zone_type = cluster_handler.cluster.get("zone_type") + def recompute_capabilities(self) -> None: + """Recompute capabilities.""" + super().recompute_capabilities() + zone_type = self._cluster_handler.cluster.get("zone_type") if zone_type is None: self._attr_translation_key = "ias_zone" @@ -268,8 +263,6 @@ def __init__( ) self._attr_device_class = IAS_ZONE_CLASS_MAPPING.get(zone_type) - super().__init__(cluster_handlers, endpoint, device, **kwargs) - @staticmethod def parse(value: bool | int) -> bool: """Parse the raw attribute into a bool state."""