From 0a42b8dec0ef0b7bdecb470e99424a05e8026512 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 13:17:12 +0000 Subject: [PATCH] Fix Roborock integration compatibility - Update `__init__.py` to support new `runtime_data` structure (dictionary of coordinators) in recent Home Assistant Core versions, while maintaining backward compatibility. - Update `image.py` to fallback to `RoborockCoordinatedEntity` if `RoborockCoordinatedEntityV1` is not found, addressing class renaming in recent Core updates. --- custom_components/roborock_custom_map/__init__.py | 15 ++++++++++++++- custom_components/roborock_custom_map/image.py | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) 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