Skip to content

Commit 1efa281

Browse files
committed
chore: add no_map constant
1 parent 1a69ae4 commit 1efa281

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
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 >> 2
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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Test cases for the containers module."""
22

3-
import copy
43
from dataclasses import dataclass
54
from typing import Any
65

@@ -488,8 +487,10 @@ def test_accurate_map_flag() -> None:
488487
"""Test that we parse the map flag accurately."""
489488
s = S7MaxVStatus.from_dict(STATUS)
490489
assert s.current_map == 0
491-
s = S7MaxVStatus.from_dict({
492-
**STATUS,
493-
"map_status": 252, # Code for no map
494-
})
495-
assert s.current_map == 63
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)