From 52c93edb53b7b47a1d37107076853d8d3236be82 Mon Sep 17 00:00:00 2001 From: Aidan Timson Date: Tue, 13 Oct 2020 13:12:01 +0100 Subject: [PATCH] Add Palette to WLED Effect Service (#41724) --- homeassistant/components/wled/light.py | 5 +++++ homeassistant/components/wled/services.yaml | 3 +++ tests/components/wled/test_light.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/homeassistant/components/wled/light.py b/homeassistant/components/wled/light.py index 6a22bf6852f..1e57dd3c1d3 100644 --- a/homeassistant/components/wled/light.py +++ b/homeassistant/components/wled/light.py @@ -67,6 +67,7 @@ async def async_setup_entry( vol.Optional(ATTR_INTENSITY): vol.All( vol.Coerce(int), vol.Range(min=0, max=255) ), + vol.Optional(ATTR_PALETTE): vol.Any(cv.positive_int, cv.string), vol.Optional(ATTR_REVERSE): cv.boolean, vol.Optional(ATTR_SPEED): vol.All( vol.Coerce(int), vol.Range(min=0, max=255) @@ -350,6 +351,7 @@ class WLEDSegmentLight(LightEntity, WLEDDeviceEntity): self, effect: Optional[Union[int, str]] = None, intensity: Optional[int] = None, + palette: Optional[Union[int, str]] = None, reverse: Optional[bool] = None, speed: Optional[int] = None, ) -> None: @@ -362,6 +364,9 @@ class WLEDSegmentLight(LightEntity, WLEDDeviceEntity): if intensity is not None: data[ATTR_INTENSITY] = intensity + if palette is not None: + data[ATTR_PALETTE] = palette + if reverse is not None: data[ATTR_REVERSE] = reverse diff --git a/homeassistant/components/wled/services.yaml b/homeassistant/components/wled/services.yaml index 90b14125ad8..7b9a8d01ba1 100644 --- a/homeassistant/components/wled/services.yaml +++ b/homeassistant/components/wled/services.yaml @@ -10,6 +10,9 @@ effect: intensity: description: Intensity of the effect example: 100 + palette: + description: Name or ID of the WLED light palette. + example: "Tiamat" speed: description: Speed of the effect. Number between 0 (slow) and 255 (fast). example: 150 diff --git a/tests/components/wled/test_light.py b/tests/components/wled/test_light.py index 66aa50cb71b..e2db58b1246 100644 --- a/tests/components/wled/test_light.py +++ b/tests/components/wled/test_light.py @@ -456,6 +456,7 @@ async def test_effect_service( ATTR_EFFECT: "Rainbow", ATTR_ENTITY_ID: "light.wled_rgb_light_segment_0", ATTR_INTENSITY: 200, + ATTR_PALETTE: "Tiamat", ATTR_REVERSE: True, ATTR_SPEED: 100, }, @@ -465,6 +466,7 @@ async def test_effect_service( light_mock.assert_called_once_with( effect="Rainbow", intensity=200, + palette="Tiamat", reverse=True, segment_id=0, speed=100, @@ -510,6 +512,7 @@ async def test_effect_service( { ATTR_EFFECT: "Rainbow", ATTR_ENTITY_ID: "light.wled_rgb_light_segment_0", + ATTR_PALETTE: "Tiamat", ATTR_REVERSE: True, ATTR_SPEED: 100, }, @@ -518,6 +521,7 @@ async def test_effect_service( await hass.async_block_till_done() light_mock.assert_called_once_with( effect="Rainbow", + palette="Tiamat", reverse=True, segment_id=0, speed=100,