diff --git a/custom_components/roborock_custom_map/__init__.py b/custom_components/roborock_custom_map/__init__.py index bc1742c..4098fc4 100644 --- a/custom_components/roborock_custom_map/__init__.py +++ b/custom_components/roborock_custom_map/__init__.py @@ -21,7 +21,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: for r_entry in roborock_entries: if r_entry.state == ConfigEntryState.LOADED: - coordinators.extend(r_entry.runtime_data.v1) + if hasattr(r_entry.runtime_data, "v1"): + # Support for older versions of Roborock integration + coordinators.extend(r_entry.runtime_data.v1) + elif isinstance(r_entry.runtime_data, dict): + # Support for newer versions where runtime_data is a dict of coordinators + coordinators.extend(r_entry.runtime_data.values()) + else: + # Fallback if runtime_data is the coordinator itself or something else + # This depends on exact structure, but assuming dict or object + # If it's a list (unlikely for typed runtime_data but possible) + if isinstance(r_entry.runtime_data, list): + coordinators.extend(r_entry.runtime_data) + # If it's something else, we can't safely extract coordinators. + # If any unload, then we should reload as well in case there are major changes. r_entry.async_on_unload(unload_this_entry) if len(coordinators) == 0: diff --git a/custom_components/roborock_custom_map/image.py b/custom_components/roborock_custom_map/image.py index eed9c39..dea057a 100644 --- a/custom_components/roborock_custom_map/image.py +++ b/custom_components/roborock_custom_map/image.py @@ -5,7 +5,10 @@ import logging from homeassistant.components.image import ImageEntity from homeassistant.components.roborock.coordinator import RoborockDataUpdateCoordinator -from homeassistant.components.roborock.entity import RoborockCoordinatedEntityV1 +try: + from homeassistant.components.roborock.entity import RoborockCoordinatedEntityV1 +except ImportError: + from homeassistant.components.roborock.entity import RoborockCoordinatedEntity as RoborockCoordinatedEntityV1 from homeassistant.config_entries import ConfigEntry from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant