Skip to content
Merged
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
2 changes: 2 additions & 0 deletions roborock/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@
ROBOROCK_P10,
ROCKROBO_G10_SG,
]

NO_MAP = 63
5 changes: 4 additions & 1 deletion roborock/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
FILTER_REPLACE_TIME,
MAIN_BRUSH_REPLACE_TIME,
MOP_ROLLER_REPLACE_TIME,
NO_MAP,
ROBOROCK_G10S_PRO,
ROBOROCK_P10,
ROBOROCK_Q7_MAX,
Expand Down Expand Up @@ -432,7 +433,9 @@ def get_mop_mode_code(self, mop_mode: str) -> int:
def current_map(self) -> int | None:
"""Returns the current map ID if the map is present."""
if self.map_status is not None:
return (self.map_status - 3) // 4
map_flag = self.map_status >> 2
if map_flag != NO_MAP:
return map_flag
return None


Expand Down
13 changes: 13 additions & 0 deletions tests/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,16 @@ def test_multi_maps_list_info(snapshot: SnapshotAssertion) -> None:
deserialized = MultiMapsList.from_dict(data)
assert isinstance(deserialized, MultiMapsList)
assert deserialized == snapshot


def test_accurate_map_flag() -> None:
"""Test that we parse the map flag accurately."""
s = S7MaxVStatus.from_dict(STATUS)
assert s.current_map == 0
s = S7MaxVStatus.from_dict(
{
**STATUS,
"map_status": 252, # Code for no map
}
)
assert s.current_map is None
Loading