diff --git a/roborock/devices/traits/b01/q7/__init__.py b/roborock/devices/traits/b01/q7/__init__.py index a48dc344..71ca213f 100644 --- a/roborock/devices/traits/b01/q7/__init__.py +++ b/roborock/devices/traits/b01/q7/__init__.py @@ -139,6 +139,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 0c04a261..92fc59f6 100644 --- a/tests/devices/traits/b01/q7/test_init.py +++ b/tests/devices/traits/b01/q7/test_init.py @@ -231,6 +231,28 @@ async def test_q7_api_set_do_not_disturb_invalid_time( assert len(fake_channel.published_messages) == 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: FakeChannel, + message_builder: B01MessageBuilder, +): + """Test toggling the button/panel lights.""" + fake_channel.response_queue.append(message_builder.build({"result": "ok"})) + await q7_api.set_button_light(enabled) + + assert len(fake_channel.published_messages) == 1 + message = fake_channel.published_messages[0] + payload_data = json.loads(unpad(message.payload, AES.block_size)) + assert payload_data["dps"]["10000"]["method"] == "prop.set" + assert payload_data["dps"]["10000"]["params"] == {RoborockB01Props.LIGHT_MODE: expected_code} + + @pytest.mark.parametrize( ("mode", "expected_code"), [