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
6 changes: 6 additions & 0 deletions roborock/data/b01_q7/b01_q7_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class Q7MapListEntry(RoborockBase):

id: int | None = None
cur: bool | None = None
name: str | None = None
"""User-visible map name as shown in the app (e.g. ``"Temporary map"`` for an unsaved map)."""


@dataclass
Expand Down Expand Up @@ -204,6 +206,10 @@ class B01Props(RoborockBase):
serial_number: str | None = None
recommend: Recommend | None = None
add_sweep_status: int | None = None
carpet_turbo: int | None = None
"""Only set when ``carpet_turbo`` is queried directly; a ``privacy`` query fills ``privacy.carpet_turbo``."""
carpet_avoid: int | None = None
"""Only set when ``carpet_avoid`` is queried directly; a ``privacy`` query fills ``privacy.carpet_avoid``."""

@property
def battery(self) -> int | None:
Expand Down
8 changes: 8 additions & 0 deletions roborock/devices/traits/b01/q7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ async def clean_zones(self, zones: list[tuple[Q7RoborockPoint, Q7RoborockPoint]]
await self.send(RoborockB01Q7Methods.SET_ZONE_POINTS, {"zone_points": zone_points})
await self.send(RoborockB01Q7Methods.SET_ZONE_CLEAN, {"ctrl_value": SCDeviceCleanParam.START.code})

async def set_carpet_turbo(self, enabled: bool) -> None:
"""Enable or disable increased suction on carpets."""
await self.set_prop(RoborockB01Props.CARPET_TURBO, int(enabled))

async def set_carpet_avoid(self, enabled: bool) -> None:
"""Enable or disable carpet avoidance."""
await self.set_prop(RoborockB01Props.CARPET_AVOID, int(enabled))

async def pause_clean(self) -> None:
"""Pause cleaning."""
await self.send(
Expand Down
4 changes: 4 additions & 0 deletions roborock/roborock_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ class RoborockB01Props(StrEnum):
SERIAL_NUMBER = "serial_number"
RECOMMEND = "recommend"
ADD_SWEEP_STATUS = "add_sweep_status"
# Settable individually via prop.set. A direct prop.get returns them top-level;
# they are also reported nested under ``privacy``.
CARPET_TURBO = "carpet_turbo"
CARPET_AVOID = "carpet_avoid"

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.

RoborockB01Props is also the parameter enum for Q7PropertiesApi.query_values(props: list[RoborockB01Props]) -> B01Props | None. While prop.get nests carpet_turbo and carpet_avoid under privacy when RoborockB01Props.PRIVACY is queried, querying carpet_turbo or carpet_avoid directly in prop.get returns top-level carpet_turbo / carpet_avoid integer fields in the response payload.

Consider also adding carpet_turbo: int | None = None and carpet_avoid: int | None = None to B01Props in roborock/data/b01_q7/b01_q7_containers.py (matching all other RoborockB01Props members, such as quiet_is_open / quiet_begin_time / quiet_end_time) so query_values([RoborockB01Props.CARPET_TURBO, RoborockB01Props.CARPET_AVOID]) does not silently drop those fields during B01Props.from_dict().

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.

Good catch, done in 318dc35: B01Props now has carpet_turbo and carpet_avoid, with a test that query_values([CARPET_TURBO, CARPET_AVOID]) keeps them.



ROBOROCK_DATA_STATUS_PROTOCOL = [
Expand Down
16 changes: 16 additions & 0 deletions tests/data/b01_q7/test_b01_q7_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CleanRecordList,
CleanRepeatMapping,
DustCollectionStateMapping,
Q7MapList,
Q7RoborockPoint,
SCWindMapping,
StationStateMapping,
Expand Down Expand Up @@ -324,3 +325,18 @@ def test_q7_roborock_point_conversion(world: tuple[float, float], common: tuple[

assert (point.x, point.y) == common
assert point.to_world() == pytest.approx(world, abs=0.001)


def test_q7_map_list_names() -> None:
"""Test map list entries keep the user-visible map name."""
map_list = Q7MapList.from_dict(
{
"map_list": [
{"name": "Home", "id": 1791875181, "cur": True},
{"name": "Temporary map", "id": 0, "cur": False},
]
}
)

assert [entry.name for entry in map_list.map_list] == ["Home", "Temporary map"]
assert map_list.current_map_id == 1791875181
33 changes: 33 additions & 0 deletions tests/devices/traits/b01/q7/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,36 @@ async def test_q7_api_clean_zones_invalid(
await q7_api.clean_zones(zones)

assert fake_channel.published_commands == []


@pytest.mark.parametrize(
("method", "prop"),
[
("set_carpet_turbo", RoborockB01Props.CARPET_TURBO),
("set_carpet_avoid", RoborockB01Props.CARPET_AVOID),
],
)
@pytest.mark.parametrize(("enabled", "expected_code"), [(True, 1), (False, 0)])
async def test_q7_api_set_carpet_settings(
method: str,
prop: RoborockB01Props,
enabled: bool,
expected_code: int,
q7_api: Q7PropertiesApi,
fake_channel: FakeQ7Channel,
):
"""Test carpet settings are written as individual properties."""
await getattr(q7_api, method)(enabled)

assert fake_channel.published_commands == [(RoborockB01Q7Methods.SET_PROP, {prop: expected_code})]


async def test_q7_api_query_carpet_settings(q7_api: Q7PropertiesApi, fake_channel: FakeQ7Channel):
"""Test carpet settings queried directly are kept as top-level properties."""
fake_channel.response_queue.append({"carpet_turbo": 1, "carpet_avoid": 0})

props = await q7_api.query_values([RoborockB01Props.CARPET_TURBO, RoborockB01Props.CARPET_AVOID])

assert props is not None
assert props.carpet_turbo == 1
assert props.carpet_avoid == 0
2 changes: 1 addition & 1 deletion tests/devices/traits/b01/q7/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ async def test_q7_map_refresh(q7_api: Q7PropertiesApi, fake_channel: FakeQ7Chann
command, params = fake_channel.published_commands[0]
assert command == RoborockB01Q7Methods.GET_MAP_LIST
assert params == {}
assert q7_api.map.map_list == [Q7MapListEntry(id=111)]
assert q7_api.map.map_list == [Q7MapListEntry(id=111, name="Map 1")]
Loading