From b39b2d161c76f487ee660d857970f58b4fbb3fb6 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Thu, 29 Feb 2024 22:43:47 +0100 Subject: [PATCH] Deconz fix gradient color mode (#111890) * Fix deconz gradient colormode * Fix gradient light not reporting color mode in deCONZ --- homeassistant/components/deconz/light.py | 1 + tests/components/deconz/test_light.py | 111 +++++++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/homeassistant/components/deconz/light.py b/homeassistant/components/deconz/light.py index 27038a07ac3..086db2058c9 100644 --- a/homeassistant/components/deconz/light.py +++ b/homeassistant/components/deconz/light.py @@ -63,6 +63,7 @@ FLASH_TO_DECONZ = {FLASH_SHORT: LightAlert.SHORT, FLASH_LONG: LightAlert.LONG} DECONZ_TO_COLOR_MODE = { LightColorMode.CT: ColorMode.COLOR_TEMP, + LightColorMode.GRADIENT: ColorMode.XY, LightColorMode.HS: ColorMode.HS, LightColorMode.XY: ColorMode.XY, } diff --git a/tests/components/deconz/test_light.py b/tests/components/deconz/test_light.py index d1d5b983956..63c544ff189 100644 --- a/tests/components/deconz/test_light.py +++ b/tests/components/deconz/test_light.py @@ -308,6 +308,117 @@ async def test_no_lights_or_groups( }, }, ), + ( # Gradient light + { + "capabilities": { + "alerts": [ + "none", + "select", + "lselect", + "blink", + "breathe", + "okay", + "channelchange", + "finish", + "stop", + ], + "bri": {"min_dim_level": 0.01}, + "color": { + "ct": {"computes_xy": True, "max": 500, "min": 153}, + "effects": [ + "none", + "colorloop", + "candle", + "fireplace", + "prism", + "sunrise", + ], + "gamut_type": "C", + "gradient": { + "max_segments": 9, + "pixel_count": 16, + "pixel_length": 1250, + "styles": ["linear", "mirrored"], + }, + "modes": ["ct", "effect", "gradient", "hs", "xy"], + "xy": { + "blue": [0.1532, 0.0475], + "green": [0.17, 0.7], + "red": [0.6915, 0.3083], + }, + }, + }, + "colorcapabilities": 31, + "config": { + "bri": { + "couple_ct": False, + "execute_if_off": True, + "startup": "previous", + }, + "color": { + "ct": {"startup": "previous"}, + "execute_if_off": True, + "gradient": {"reversed": False}, + "xy": {"startup": "previous"}, + }, + "groups": ["36", "39", "45", "46", "47", "51", "57", "59"], + "on": {"startup": "previous"}, + }, + "ctmax": 500, + "ctmin": 153, + "etag": "077fb97dd6145f10a3c190f0a1ade499", + "hascolor": True, + "lastannounced": None, + "lastseen": "2024-02-29T18:36Z", + "manufacturername": "Signify Netherlands B.V.", + "modelid": "LCX004", + "name": "Gradient light", + "productid": "Philips-LCX004-1-GALSECLv1", + "productname": "Hue gradient lightstrip", + "state": { + "alert": "none", + "bri": 184, + "colormode": "gradient", + "ct": 396, + "effect": "none", + "gradient": { + "color_adjustment": 0, + "offset": 0, + "offset_adjustment": 0, + "points": [ + [0.2728, 0.6226], + [0.163, 0.4262], + [0.1563, 0.1699], + [0.1551, 0.1147], + [0.1534, 0.0579], + ], + "segments": 5, + "style": "linear", + }, + "hue": 20566, + "on": True, + "reachable": True, + "sat": 254, + "xy": [0.2727, 0.6226], + }, + "swconfigid": "F03CAF4D", + "swversion": "1.104.2", + "type": "Extended color light", + "uniqueid": "00:17:88:01:0b:0c:0d:0e-0f", + }, + { + "entity_id": "light.gradient_light", + "state": STATE_ON, + "attributes": { + ATTR_SUPPORTED_COLOR_MODES: [ + ColorMode.COLOR_TEMP, + ColorMode.HS, + ColorMode.XY, + ], + ATTR_COLOR_MODE: ColorMode.XY, + }, + }, + ), ], ) async def test_lights(