From b17019e762d7338624fab41c6490d6274740ce08 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Wed, 8 Mar 2023 04:39:20 +0100 Subject: [PATCH] roborock: guard current_map_id access (#1760) This makes it not to crash on access on older devices where this isn't available. --- miio/integrations/roborock/vacuum/vacuumcontainers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/miio/integrations/roborock/vacuum/vacuumcontainers.py b/miio/integrations/roborock/vacuum/vacuumcontainers.py index ef52a0dff..4a08a30bd 100644 --- a/miio/integrations/roborock/vacuum/vacuumcontainers.py +++ b/miio/integrations/roborock/vacuum/vacuumcontainers.py @@ -331,12 +331,15 @@ def map(self) -> bool: setter_name="load_map", icon="mdi:floor-plan", ) - def current_map_id(self) -> int: + def current_map_id(self) -> Optional[int]: """The id of the current map with regards to the multi map feature, [3,7,11,15] -> [0,1,2,3]. """ - return int((self.data["map_status"] + 1) / 4 - 1) + try: + return int((self.data["map_status"] + 1) / 4 - 1) + except KeyError: + return None @property def in_zone_cleaning(self) -> bool: