From a6b920b165c92842c47ac848956f0e2066a2dfe6 Mon Sep 17 00:00:00 2001 From: Thomas Rupprecht Date: Wed, 3 Jun 2026 23:58:28 +0200 Subject: [PATCH] feat(q7): add set_button_light trait method Co-Authored-By: Claude Opus 4.8 (1M context) --- roborock/devices/traits/b01/q7/__init__.py | 4 ++++ tests/devices/traits/b01/q7/test_init.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/roborock/devices/traits/b01/q7/__init__.py b/roborock/devices/traits/b01/q7/__init__.py index 35a29144..7084fc55 100644 --- a/roborock/devices/traits/b01/q7/__init__.py +++ b/roborock/devices/traits/b01/q7/__init__.py @@ -140,6 +140,10 @@ async def set_do_not_disturb(self, enabled: bool, begin_time: int, end_time: int }, ) + async def set_button_light(self, enabled: bool) -> None: + """Enable or disable the button/panel lights.""" + await self.set_prop(RoborockB01Props.LIGHT_MODE, int(enabled)) + async def start_clean(self) -> None: """Start cleaning.""" await self.send( diff --git a/tests/devices/traits/b01/q7/test_init.py b/tests/devices/traits/b01/q7/test_init.py index c273d2d4..9bbc591d 100644 --- a/tests/devices/traits/b01/q7/test_init.py +++ b/tests/devices/traits/b01/q7/test_init.py @@ -171,6 +171,26 @@ async def test_q7_api_set_do_not_disturb_invalid_time( assert len(fake_channel.published_commands) == 0 +@pytest.mark.parametrize( + ("enabled", "expected_code"), + [(True, 1), (False, 0)], +) +async def test_q7_api_set_button_light( + enabled: bool, + expected_code: int, + q7_api: Q7PropertiesApi, + fake_channel: FakeQ7Channel, +): + """Test toggling the button/panel lights.""" + fake_channel.response_queue.append({"result": "ok"}) + await q7_api.set_button_light(enabled) + + assert len(fake_channel.published_commands) == 1 + command, params = fake_channel.published_commands[0] + assert command == RoborockB01Q7Methods.SET_PROP + assert params == {RoborockB01Props.LIGHT_MODE: expected_code} + + @pytest.mark.parametrize( ("mode", "expected_code"), [