From a55ed9e8a2d12f372a16bb4d9ccd41e760dcd1ed Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 22 Sep 2025 10:57:17 -0400 Subject: [PATCH 1/4] fix: the map id --- roborock/containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roborock/containers.py b/roborock/containers.py index 1cb10034..47222c86 100644 --- a/roborock/containers.py +++ b/roborock/containers.py @@ -432,7 +432,7 @@ 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 + return self.map_status >> 2 return None From bdeeb18fdba5fa1a37d9be1f69d5e4c7cda67a30 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 27 Sep 2025 21:46:25 -0400 Subject: [PATCH 2/4] chore: add test --- tests/test_containers.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_containers.py b/tests/test_containers.py index 58832b09..52095293 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -1,5 +1,6 @@ """Test cases for the containers module.""" +import copy from dataclasses import dataclass from typing import Any @@ -481,3 +482,14 @@ 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 + status = copy.deepcopy(STATUS) + # 252 is a code for no map, it should end up being 63. + status["map_status"] = 252 + s = S7MaxVStatus.from_dict(status) + assert s.current_map == 63 From 1a69ae41c3c0e9f987b6b82ac234338e3ed0f917 Mon Sep 17 00:00:00 2001 From: Luke Lashley Date: Sat, 27 Sep 2025 23:15:07 -0400 Subject: [PATCH 3/4] Update test_containers.py Co-authored-by: Allen Porter --- tests/test_containers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_containers.py b/tests/test_containers.py index 52095293..1136ffa1 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -488,8 +488,8 @@ def test_accurate_map_flag() -> None: """Test that we parse the map flag accurately.""" s = S7MaxVStatus.from_dict(STATUS) assert s.current_map == 0 - status = copy.deepcopy(STATUS) - # 252 is a code for no map, it should end up being 63. - status["map_status"] = 252 - s = S7MaxVStatus.from_dict(status) + s = S7MaxVStatus.from_dict({ + **STATUS, + "map_status": 252, # Code for no map + }) assert s.current_map == 63 From 1efa281e22adaa03d8c2e9d7a84a23b27f4a9546 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 28 Sep 2025 20:38:35 -0400 Subject: [PATCH 4/4] chore: add no_map constant --- roborock/const.py | 2 ++ roborock/containers.py | 5 ++++- tests/test_containers.py | 13 +++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/roborock/const.py b/roborock/const.py index 2c0c973c..b8ed64fe 100644 --- a/roborock/const.py +++ b/roborock/const.py @@ -78,3 +78,5 @@ ROBOROCK_P10, ROCKROBO_G10_SG, ] + +NO_MAP = 63 diff --git a/roborock/containers.py b/roborock/containers.py index 47222c86..6433723d 100644 --- a/roborock/containers.py +++ b/roborock/containers.py @@ -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, @@ -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 >> 2 + map_flag = self.map_status >> 2 + if map_flag != NO_MAP: + return map_flag return None diff --git a/tests/test_containers.py b/tests/test_containers.py index 1136ffa1..c2c8b5dd 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -1,6 +1,5 @@ """Test cases for the containers module.""" -import copy from dataclasses import dataclass from typing import Any @@ -488,8 +487,10 @@ 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 == 63 + s = S7MaxVStatus.from_dict( + { + **STATUS, + "map_status": 252, # Code for no map + } + ) + assert s.current_map is None