Skip to content

Commit d7d0a3b

Browse files
Lash-Lallenporter
andauthored
fix: broken current map logic (#497)
* fix: the map id * chore: add test * chore: add no_map constant --------- Co-authored-by: Allen Porter <[email protected]>
1 parent da5d80f commit d7d0a3b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

roborock/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@
7878
ROBOROCK_P10,
7979
ROCKROBO_G10_SG,
8080
]
81+
82+
NO_MAP = 63

roborock/containers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
FILTER_REPLACE_TIME,
6666
MAIN_BRUSH_REPLACE_TIME,
6767
MOP_ROLLER_REPLACE_TIME,
68+
NO_MAP,
6869
ROBOROCK_G10S_PRO,
6970
ROBOROCK_P10,
7071
ROBOROCK_Q7_MAX,
@@ -432,7 +433,9 @@ def get_mop_mode_code(self, mop_mode: str) -> int:
432433
def current_map(self) -> int | None:
433434
"""Returns the current map ID if the map is present."""
434435
if self.map_status is not None:
435-
return (self.map_status - 3) // 4
436+
map_flag = self.map_status >> 2
437+
if map_flag != NO_MAP:
438+
return map_flag
436439
return None
437440

438441

tests/test_containers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,16 @@ def test_multi_maps_list_info(snapshot: SnapshotAssertion) -> None:
481481
deserialized = MultiMapsList.from_dict(data)
482482
assert isinstance(deserialized, MultiMapsList)
483483
assert deserialized == snapshot
484+
485+
486+
def test_accurate_map_flag() -> None:
487+
"""Test that we parse the map flag accurately."""
488+
s = S7MaxVStatus.from_dict(STATUS)
489+
assert s.current_map == 0
490+
s = S7MaxVStatus.from_dict(
491+
{
492+
**STATUS,
493+
"map_status": 252, # Code for no map
494+
}
495+
)
496+
assert s.current_map is None

0 commit comments

Comments
 (0)