mirror of
https://github.com/home-assistant/core.git
synced 2025-04-29 11:47:50 +00:00
Avoid exposing effects to flux_led lights that do not support them (#57810)
This commit is contained in:
parent
8405331204
commit
76b6fce19c
@ -92,7 +92,7 @@ from .entity import FluxEntity
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SUPPORT_FLUX_LED: Final = SUPPORT_EFFECT | SUPPORT_TRANSITION
|
SUPPORT_FLUX_LED: Final = SUPPORT_TRANSITION
|
||||||
|
|
||||||
|
|
||||||
FLUX_COLOR_MODE_TO_HASS: Final = {
|
FLUX_COLOR_MODE_TO_HASS: Final = {
|
||||||
@ -103,6 +103,7 @@ FLUX_COLOR_MODE_TO_HASS: Final = {
|
|||||||
FLUX_COLOR_MODE_DIM: COLOR_MODE_BRIGHTNESS,
|
FLUX_COLOR_MODE_DIM: COLOR_MODE_BRIGHTNESS,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFFECT_SUPPORT_MODES = {COLOR_MODE_RGB, COLOR_MODE_RGBW, COLOR_MODE_RGBWW}
|
||||||
|
|
||||||
# Constant color temp values for 2 flux_led special modes
|
# Constant color temp values for 2 flux_led special modes
|
||||||
# Warm-white and Cool-white modes
|
# Warm-white and Cool-white modes
|
||||||
@ -299,9 +300,11 @@ class FluxLight(FluxEntity, CoordinatorEntity, LightEntity):
|
|||||||
FLUX_COLOR_MODE_TO_HASS.get(mode, COLOR_MODE_ONOFF)
|
FLUX_COLOR_MODE_TO_HASS.get(mode, COLOR_MODE_ONOFF)
|
||||||
for mode in self._device.color_modes
|
for mode in self._device.color_modes
|
||||||
}
|
}
|
||||||
self._attr_effect_list = FLUX_EFFECT_LIST
|
if self._attr_supported_color_modes.intersection(EFFECT_SUPPORT_MODES):
|
||||||
if custom_effect_colors:
|
self._attr_supported_features |= SUPPORT_EFFECT
|
||||||
self._attr_effect_list = [*FLUX_EFFECT_LIST, EFFECT_CUSTOM]
|
self._attr_effect_list = FLUX_EFFECT_LIST
|
||||||
|
if custom_effect_colors:
|
||||||
|
self._attr_effect_list = [*FLUX_EFFECT_LIST, EFFECT_CUSTOM]
|
||||||
self._custom_effect_colors = custom_effect_colors
|
self._custom_effect_colors = custom_effect_colors
|
||||||
self._custom_effect_speed_pct = custom_effect_speed_pct
|
self._custom_effect_speed_pct = custom_effect_speed_pct
|
||||||
self._custom_effect_transition = custom_effect_transition
|
self._custom_effect_transition = custom_effect_transition
|
||||||
|
@ -638,6 +638,7 @@ async def test_white_light(hass: HomeAssistant) -> None:
|
|||||||
assert attributes[ATTR_BRIGHTNESS] == 128
|
assert attributes[ATTR_BRIGHTNESS] == 128
|
||||||
assert attributes[ATTR_COLOR_MODE] == "brightness"
|
assert attributes[ATTR_COLOR_MODE] == "brightness"
|
||||||
assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["brightness"]
|
assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["brightness"]
|
||||||
|
assert ATTR_EFFECT_LIST not in attributes # single channel does not support effects
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
LIGHT_DOMAIN, "turn_off", {ATTR_ENTITY_ID: entity_id}, blocking=True
|
LIGHT_DOMAIN, "turn_off", {ATTR_ENTITY_ID: entity_id}, blocking=True
|
||||||
@ -897,7 +898,9 @@ async def test_addressable_light(hass: HomeAssistant) -> None:
|
|||||||
assert state.state == STATE_ON
|
assert state.state == STATE_ON
|
||||||
attributes = state.attributes
|
attributes = state.attributes
|
||||||
assert attributes[ATTR_COLOR_MODE] == "onoff"
|
assert attributes[ATTR_COLOR_MODE] == "onoff"
|
||||||
assert attributes[ATTR_EFFECT_LIST] == FLUX_EFFECT_LIST
|
assert (
|
||||||
|
ATTR_EFFECT_LIST not in attributes
|
||||||
|
) # no support for effects with addressable yet
|
||||||
assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["onoff"]
|
assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["onoff"]
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user