From 665a2889ec1b2306d24e86a948a97b0791e86dc0 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Wed, 25 Jan 2023 12:18:23 +0100 Subject: [PATCH] Add group support for ZHA ExecuteIfOff lights (#86465) Add group support for ZHA "execute if off" lights --- homeassistant/components/zha/light.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index 16747869efc..be21d704062 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -189,9 +189,9 @@ class BaseLight(LogMixin, light.LightEntity): hs_color = kwargs.get(light.ATTR_HS_COLOR) execute_if_off_supported = ( - not isinstance(self, LightGroup) - and self._color_channel - and self._color_channel.execute_if_off_supported + self._GROUP_SUPPORTS_EXECUTE_IF_OFF + if isinstance(self, LightGroup) + else self._color_channel and self._color_channel.execute_if_off_supported ) set_transition_flag = ( @@ -1049,6 +1049,20 @@ class LightGroup(BaseLight, ZhaGroupEntity): """Initialize a light group.""" super().__init__(entity_ids, unique_id, group_id, zha_device, **kwargs) group = self.zha_device.gateway.get_group(self._group_id) + + self._GROUP_SUPPORTS_EXECUTE_IF_OFF = True # pylint: disable=invalid-name + # Check all group members to see if they support execute_if_off. + # If at least one member has a color cluster and doesn't support it, it's not used. + for member in group.members: + for pool in member.device.channels.pools: + for channel in pool.all_channels.values(): + if ( + channel.name == CHANNEL_COLOR + and not channel.execute_if_off_supported + ): + self._GROUP_SUPPORTS_EXECUTE_IF_OFF = False + break + self._DEFAULT_MIN_TRANSITION_TIME = any( # pylint: disable=invalid-name member.device.manufacturer in DEFAULT_MIN_TRANSITION_MANUFACTURERS for member in group.members