From a691bd26cfb8e18961efced37f53a6895a88822b Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Wed, 25 Oct 2023 00:32:20 +0200 Subject: [PATCH] Support Lidl christmas light effects in deCONZ (#102731) --- homeassistant/components/deconz/light.py | 43 +++++++++++++++++++++++- tests/components/deconz/test_light.py | 20 ++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/deconz/light.py b/homeassistant/components/deconz/light.py index 47ca1eda0d8..dc2ed04b4ed 100644 --- a/homeassistant/components/deconz/light.py +++ b/homeassistant/components/deconz/light.py @@ -38,7 +38,27 @@ from .deconz_device import DeconzDevice from .gateway import DeconzGateway, get_gateway_from_config_entry DECONZ_GROUP = "is_deconz_group" -EFFECT_TO_DECONZ = {EFFECT_COLORLOOP: LightEffect.COLOR_LOOP, "None": LightEffect.NONE} +EFFECT_TO_DECONZ = { + EFFECT_COLORLOOP: LightEffect.COLOR_LOOP, + "None": LightEffect.NONE, + # Specific to Lidl christmas light + "carnival": LightEffect.CARNIVAL, + "collide": LightEffect.COLLIDE, + "fading": LightEffect.FADING, + "fireworks": LightEffect.FIREWORKS, + "flag": LightEffect.FLAG, + "glow": LightEffect.GLOW, + "rainbow": LightEffect.RAINBOW, + "snake": LightEffect.SNAKE, + "snow": LightEffect.SNOW, + "sparkles": LightEffect.SPARKLES, + "steady": LightEffect.STEADY, + "strobe": LightEffect.STROBE, + "twinkle": LightEffect.TWINKLE, + "updown": LightEffect.UPDOWN, + "vintage": LightEffect.VINTAGE, + "waves": LightEffect.WAVES, +} FLASH_TO_DECONZ = {FLASH_SHORT: LightAlert.SHORT, FLASH_LONG: LightAlert.LONG} DECONZ_TO_COLOR_MODE = { @@ -47,6 +67,25 @@ DECONZ_TO_COLOR_MODE = { LightColorMode.XY: ColorMode.XY, } +TS0601_EFFECTS = [ + "carnival", + "collide", + "fading", + "fireworks", + "flag", + "glow", + "rainbow", + "snake", + "snow", + "sparkles", + "steady", + "strobe", + "twinkle", + "updown", + "vintage", + "waves", +] + _LightDeviceT = TypeVar("_LightDeviceT", bound=Group | Light) @@ -161,6 +200,8 @@ class DeconzBaseLight(DeconzDevice[_LightDeviceT], LightEntity): if device.effect is not None: self._attr_supported_features |= LightEntityFeature.EFFECT self._attr_effect_list = [EFFECT_COLORLOOP] + if device.model_id == "TS0601": + self._attr_effect_list += TS0601_EFFECTS @property def color_mode(self) -> str | None: diff --git a/tests/components/deconz/test_light.py b/tests/components/deconz/test_light.py index f6c4452dac6..357371e4853 100644 --- a/tests/components/deconz/test_light.py +++ b/tests/components/deconz/test_light.py @@ -185,7 +185,25 @@ async def test_no_lights_or_groups( "entity_id": "light.lidl_xmas_light", "state": STATE_ON, "attributes": { - ATTR_EFFECT_LIST: [EFFECT_COLORLOOP], + ATTR_EFFECT_LIST: [ + EFFECT_COLORLOOP, + "carnival", + "collide", + "fading", + "fireworks", + "flag", + "glow", + "rainbow", + "snake", + "snow", + "sparkles", + "steady", + "strobe", + "twinkle", + "updown", + "vintage", + "waves", + ], ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], ATTR_COLOR_MODE: ColorMode.HS, ATTR_BRIGHTNESS: 25,