Skip to content

Commit

Permalink
roborock: guard current_map_id access (#1760)
Browse files Browse the repository at this point in the history
This makes it not to crash on access on older devices where this isn't
available.
  • Loading branch information
rytilahti authored Mar 8, 2023
1 parent c32761c commit b17019e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions miio/integrations/roborock/vacuum/vacuumcontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b17019e

Please sign in to comment.