From 3ed1de60c6717bebf8f0025e36e737c792e60db8 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sun, 10 Aug 2025 07:30:50 -0700 Subject: [PATCH 1/2] feat: Add property for accessing the current map from the status object --- roborock/containers.py | 7 +++++++ tests/test_containers.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/roborock/containers.py b/roborock/containers.py index e293984c..3ad7d53c 100644 --- a/roborock/containers.py +++ b/roborock/containers.py @@ -425,6 +425,13 @@ def get_mop_mode_code(self, mop_mode: str) -> int: raise RoborockException("Attempted to get mop_mode before status has been updated.") return self.mop_mode.as_dict().get(mop_mode) + @property + 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 None + @dataclass class S4MaxStatus(Status): diff --git a/tests/test_containers.py b/tests/test_containers.py index 1f0bda70..ff3d4503 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -234,6 +234,7 @@ def test_status(): assert s.fan_power == 102 assert s.dnd_enabled == 0 assert s.map_status == 3 + assert s.current_map == 0 assert s.is_locating == 0 assert s.lock_status == 0 assert s.water_box_mode == 203 @@ -262,6 +263,19 @@ def test_status(): assert s.water_box_mode == RoborockMopIntensityS7.intense +def test_current_map() -> None: + """Test the current map logic based on map status.""" + s = S7MaxVStatus.from_dict(STATUS) + assert s.map_status == 3 + assert s.current_map == 0 + + s.map_status = 7 + assert s.current_map == 1 + + s.map_status = 11 + assert s.current_map == 2 + + def test_dnd_timer(): dnd = DnDTimer.from_dict(DND_TIMER) assert dnd.start_hour == 22 From 697aafb8a1d574533bca8267b71a0c88398f6318 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sun, 10 Aug 2025 07:31:58 -0700 Subject: [PATCH 2/2] fix: add test where current_map is none --- tests/test_containers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_containers.py b/tests/test_containers.py index ff3d4503..25fc7fd4 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -275,6 +275,9 @@ def test_current_map() -> None: s.map_status = 11 assert s.current_map == 2 + s.map_status = None + assert not s.current_map + def test_dnd_timer(): dnd = DnDTimer.from_dict(DND_TIMER)