Blacklist availability check for a light at startup in Hue integration (#61737)
parent
eb345bfdf1
commit
89a6640b82
|
@ -47,6 +47,20 @@ class HueBaseEntity(Entity):
|
|||
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
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
@ -98,13 +112,12 @@ class HueBaseEntity(Entity):
|
|||
def available(self) -> bool:
|
||||
"""Return entity availability."""
|
||||
if self.device is None:
|
||||
# devices without a device attached should be always available
|
||||
# entities without a device attached should be always available
|
||||
return True
|
||||
if self.resource.type == ResourceTypes.ZIGBEE_CONNECTIVITY:
|
||||
# the zigbee connectivity sensor itself should be always available
|
||||
return True
|
||||
if self.device.product_data.manufacturer_name != "Signify Netherlands B.V.":
|
||||
# availability status for non-philips brand lights is unreliable
|
||||
if self._ignore_availability:
|
||||
return True
|
||||
if zigbee := self.bridge.api.devices.get_zigbee_connectivity(self.device.id):
|
||||
# all device-attached entities get availability from the zigbee connectivity
|
||||
|
|
Loading…
Reference in New Issue