Esempio n. 1
0
    def __init__(
        self,
        bridge: HueBridge,
        controller: BaseResourcesController,
        resource: CLIPResource,
    ) -> None:
        """Initialize a generic Hue resource entity."""
        self.bridge = bridge
        self.controller = controller
        self.resource = resource
        self.device = controller.get_device(resource.id)
        self.logger = bridge.logger.getChild(resource.type.value)

        # Entity class attributes
        self._attr_unique_id = resource.id
        # device is precreated in main handler
        # this attaches the entity to the precreated device
        if self.device is not None:
            self._attr_device_info = DeviceInfo(
                identifiers={(DOMAIN, self.device.id)},
            )
Esempio n. 2
0
    def __init__(
        self,
        bridge: HueBridge,
        controller: BaseResourcesController,
        resource: CLIPResource,
    ) -> None:
        """Initialize a generic Hue resource entity."""
        self.bridge = bridge
        self.controller = controller
        self.resource = resource
        self.device = controller.get_device(resource.id)
        self.logger = bridge.logger.getChild(resource.type.value)

        # Entity class attributes
        self._attr_unique_id = resource.id
        # device is precreated in main handler
        # this attaches the entity to the precreated device
        if self.device is not None:
            self._attr_device_info = DeviceInfo(identifiers={
                (DOMAIN, self.device.id)
            }, )
        # some (3th party) Hue lights report their connection status incorrectly
        # causing the zigbee availability to report as disconnected while in fact
        # it can be controlled. Although this is in fact something the device manufacturer
        # should fix, we work around it here. If the light is reported unavailable at
        # startup, we ignore the availability status of the zigbee connection
        self._ignore_availability = False
        if self.device is None:
            return
        if zigbee := self.bridge.api.devices.get_zigbee_connectivity(
                self.device.id):
            self._ignore_availability = (
                # Official Hue lights are reliable
                self.device.product_data.manufacturer_name !=
                "Signify Netherlands B.V."
                and zigbee.status != ConnectivityServiceStatus.CONNECTED)