Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions roborock/devices/traits/b01/q7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Comment on lines +142 to +144

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would not change that. @Lash-L should i do (a) or (b) or nothing?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's actually fine as is. Can you change make the function plural though? As it is multiple buttons lights right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe match how we describe it for v1. I think we call it led something?


async def start_clean(self) -> None:
"""Start cleaning."""
await self.send(
Expand Down
22 changes: 22 additions & 0 deletions tests/devices/traits/b01/q7/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
)
Comment thread
ximex marked this conversation as resolved.
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"),
[
Expand Down
Loading