From 52acc4bbab638fff8e799883d0b6758679fb7dfd Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 15 Jan 2024 11:08:38 +0100 Subject: [PATCH] Fix turning on the light with a specific color (#108080) --- homeassistant/components/matter/light.py | 12 ++++++++++++ tests/components/matter/test_light.py | 12 +++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/matter/light.py b/homeassistant/components/matter/light.py index 52a6b4162fe..43c47046162 100644 --- a/homeassistant/components/matter/light.py +++ b/homeassistant/components/matter/light.py @@ -89,6 +89,10 @@ class MatterLight(MatterEntity, LightEntity): colorY=int(matter_xy[1]), # It's required in TLV. We don't implement transition time yet. transitionTime=0, + # allow setting the color while the light is off, + # by setting the optionsMask to 1 (=ExecuteIfOff) + optionsMask=1, + optionsOverride=1, ) ) @@ -103,6 +107,10 @@ class MatterLight(MatterEntity, LightEntity): saturation=int(matter_hs[1]), # It's required in TLV. We don't implement transition time yet. transitionTime=0, + # allow setting the color while the light is off, + # by setting the optionsMask to 1 (=ExecuteIfOff) + optionsMask=1, + optionsOverride=1, ) ) @@ -114,6 +122,10 @@ class MatterLight(MatterEntity, LightEntity): colorTemperatureMireds=color_temp, # It's required in TLV. We don't implement transition time yet. transitionTime=0, + # allow setting the color while the light is off, + # by setting the optionsMask to 1 (=ExecuteIfOff) + optionsMask=1, + optionsOverride=1, ) ) diff --git a/tests/components/matter/test_light.py b/tests/components/matter/test_light.py index 78ffa477b33..fb988d26a1c 100644 --- a/tests/components/matter/test_light.py +++ b/tests/components/matter/test_light.py @@ -202,6 +202,8 @@ async def test_color_temperature_light( command=clusters.ColorControl.Commands.MoveToColorTemperature( colorTemperatureMireds=300, transitionTime=0, + optionsMask=1, + optionsOverride=1, ), ), call( @@ -278,7 +280,11 @@ async def test_extended_color_light( node_id=light_node.node_id, endpoint_id=1, command=clusters.ColorControl.Commands.MoveToColor( - colorX=0.5 * 65536, colorY=0.5 * 65536, transitionTime=0 + colorX=0.5 * 65536, + colorY=0.5 * 65536, + transitionTime=0, + optionsMask=1, + optionsOverride=1, ), ), call( @@ -311,8 +317,8 @@ async def test_extended_color_light( hue=167, saturation=254, transitionTime=0, - optionsMask=0, - optionsOverride=0, + optionsMask=1, + optionsOverride=1, ), ), call(