Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter ZHA light group color modes #108861

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dmulcahey marked this conversation as resolved.
Show resolved Hide resolved
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
Loading