Skip to content

Commit

Permalink
Fix turning on the light with a specific color (#108080)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Jan 15, 2024
1 parent 5cc1a76 commit 52acc4b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions homeassistant/components/matter/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ async def _set_xy_color(self, xy_color: tuple[float, float]) -> None:
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,
)
)

Expand All @@ -103,6 +107,10 @@ async def _set_hs_color(self, hs_color: tuple[float, float]) -> None:
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,
)
)

Expand All @@ -114,6 +122,10 @@ async def _set_color_temp(self, color_temp: int) -> None:
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,
)
)

Expand Down
12 changes: 9 additions & 3 deletions tests/components/matter/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ async def test_color_temperature_light(
command=clusters.ColorControl.Commands.MoveToColorTemperature(
colorTemperatureMireds=300,
transitionTime=0,
optionsMask=1,
optionsOverride=1,
),
),
call(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 52acc4b

Please sign in to comment.