Skip to content

Commit 0a42b8d

Browse files
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.
1 parent c05872c commit 0a42b8d

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

custom_components/roborock_custom_map/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,20 @@ async def unload_this_entry():
2121

2222
for r_entry in roborock_entries:
2323
if r_entry.state == ConfigEntryState.LOADED:
24-
coordinators.extend(r_entry.runtime_data.v1)
24+
if hasattr(r_entry.runtime_data, "v1"):
25+
# Support for older versions of Roborock integration
26+
coordinators.extend(r_entry.runtime_data.v1)
27+
elif isinstance(r_entry.runtime_data, dict):
28+
# Support for newer versions where runtime_data is a dict of coordinators
29+
coordinators.extend(r_entry.runtime_data.values())
30+
else:
31+
# Fallback if runtime_data is the coordinator itself or something else
32+
# This depends on exact structure, but assuming dict or object
33+
# If it's a list (unlikely for typed runtime_data but possible)
34+
if isinstance(r_entry.runtime_data, list):
35+
coordinators.extend(r_entry.runtime_data)
36+
# If it's something else, we can't safely extract coordinators.
37+
2538
# If any unload, then we should reload as well in case there are major changes.
2639
r_entry.async_on_unload(unload_this_entry)
2740
if len(coordinators) == 0:

custom_components/roborock_custom_map/image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
from homeassistant.components.image import ImageEntity
77
from homeassistant.components.roborock.coordinator import RoborockDataUpdateCoordinator
8-
from homeassistant.components.roborock.entity import RoborockCoordinatedEntityV1
8+
try:
9+
from homeassistant.components.roborock.entity import RoborockCoordinatedEntityV1
10+
except ImportError:
11+
from homeassistant.components.roborock.entity import RoborockCoordinatedEntity as RoborockCoordinatedEntityV1
912
from homeassistant.config_entries import ConfigEntry
1013
from homeassistant.const import EntityCategory
1114
from homeassistant.core import HomeAssistant

0 commit comments

Comments
 (0)