Skip to content

Commit

Permalink
Fix when the Roborock map is being provisioned (home-assistant#130574)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lash-L authored Nov 14, 2024
1 parent 2fda4c8 commit 938b1ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions homeassistant/components/roborock/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import asyncio
from datetime import timedelta
import logging

Expand Down Expand Up @@ -107,8 +106,12 @@ async def _update_device_prop(self) -> None:
async def _async_update_data(self) -> DeviceProp:
"""Update data via library."""
try:
await asyncio.gather(*(self._update_device_prop(), self.get_rooms()))
# Update device props and standard api information
await self._update_device_prop()
# Set the new map id from the updated device props
self._set_current_map()
# Get the rooms for that map id.
await self.get_rooms()
except RoborockException as ex:
raise UpdateFailed(ex) from ex
return self.roborock_device_info.props
Expand Down
8 changes: 7 additions & 1 deletion homeassistant/components/roborock/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ async def async_select_option(self, option: str) -> None:
RoborockCommand.LOAD_MULTI_MAP,
[map_id],
)
# Update the current map id manually so that nothing gets broken
# if another service hits the api.
self.coordinator.current_map = map_id
# We need to wait after updating the map
# so that other commands will be executed correctly.
await asyncio.sleep(MAP_SLEEP)
Expand All @@ -148,6 +151,9 @@ def options(self) -> list[str]:
@property
def current_option(self) -> str | None:
"""Get the current status of the select entity from device_status."""
if (current_map := self.coordinator.current_map) is not None:
if (
(current_map := self.coordinator.current_map) is not None
and current_map in self.coordinator.maps
): # 63 means it is searching for a map.
return self.coordinator.maps[current_map].name
return None

0 comments on commit 938b1ec

Please sign in to comment.