Skip to content

Commit

Permalink
Filter ZHA light group color modes (#108861)
Browse files Browse the repository at this point in the history
Ensure ZHA light color modes have proper defaults and are filtered
  • Loading branch information
puddly committed Jan 30, 2024
1 parent 4ec3a17 commit 7fbfd44
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions homeassistant/components/zha/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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
Expand Down Expand Up @@ -1183,7 +1183,9 @@ def __init__(
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
Expand Down Expand Up @@ -1283,7 +1285,6 @@ async def async_update(self) -> None:
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)
)
Expand All @@ -1301,14 +1302,13 @@ async def async_update(self) -> None:
): # 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)
Expand Down

0 comments on commit 7fbfd44

Please sign in to comment.