Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 1 addition & 1 deletion roborock/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
12 changes: 12 additions & 0 deletions tests/test_containers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test cases for the containers module."""

import copy
from dataclasses import dataclass
from typing import Any

Expand Down Expand Up @@ -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