From 7fbfd446369b8ff4526a92a2018eb00da278e383 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:14:03 -0500 Subject: [PATCH] Filter ZHA light group color modes (#108861) Ensure ZHA light color modes have proper defaults and are filtered --- homeassistant/components/zha/light.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index 486b043b450..84399f3da32 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -8,7 +8,7 @@ import functools import itertools import logging import random -from typing import TYPE_CHECKING, Any, cast +from typing import TYPE_CHECKING, Any from zigpy.zcl.clusters.general import Identify, LevelControl, OnOff from zigpy.zcl.clusters.lighting import Color @@ -1183,7 +1183,9 @@ class LightGroup(BaseLight, ZhaGroupEntity): if self._zha_config_group_members_assume_state: self._update_group_from_child_delay = ASSUME_UPDATE_GROUP_FROM_CHILD_DELAY self._zha_config_enhanced_light_transition = False - self._attr_color_mode = None + + self._attr_color_mode = ColorMode.UNKNOWN + self._attr_supported_color_modes = set() # remove this when all ZHA platforms and base entities are updated @property @@ -1283,7 +1285,6 @@ class LightGroup(BaseLight, ZhaGroupEntity): effects_count = Counter(itertools.chain(all_effects)) self._attr_effect = effects_count.most_common(1)[0][0] - self._attr_color_mode = None all_color_modes = list( helpers.find_state_attributes(on_states, light.ATTR_COLOR_MODE) ) @@ -1301,14 +1302,13 @@ class LightGroup(BaseLight, ZhaGroupEntity): ): # switch to XY if all members do not support HS self._attr_color_mode = ColorMode.XY - self._attr_supported_color_modes = None - all_supported_color_modes = list( + all_supported_color_modes: list[set[ColorMode]] = list( helpers.find_state_attributes(states, light.ATTR_SUPPORTED_COLOR_MODES) ) if all_supported_color_modes: # Merge all color modes. - self._attr_supported_color_modes = cast( - set[str], set().union(*all_supported_color_modes) + self._attr_supported_color_modes = filter_supported_color_modes( + set().union(*all_supported_color_modes) ) self._attr_supported_features = LightEntityFeature(0)