Skip to content

Commit a179410

Browse files
committed
fix: Fix issues with the cache clobbering information for each device
1 parent 88b2055 commit a179410

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

roborock/devices/cache.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,75 @@
99
from typing import Any, Protocol
1010

1111
from roborock.data import CombinedMapInfo, HomeData, NetworkInfo, RoborockBase
12+
from roborock.data.containers import RoborockBase
1213
from roborock.device_features import DeviceFeatures
1314

1415

16+
@dataclass
17+
class DeviceCacheData(RoborockBase):
18+
"""Data structure for caching device information."""
19+
20+
network_info: NetworkInfo | None = None
21+
"""Network information indexed by device DUID."""
22+
23+
home_map_info: CombinedMapInfo | None = None
24+
"""Home map information for the device."""
25+
26+
home_map_content_base64: str | None = None
27+
"""Home cache content for the device (encoded base64)."""
28+
29+
device_features: DeviceFeatures | None = None
30+
"""Device features information."""
31+
32+
trait_data: dict[str, Any] | None = None
33+
"""Trait-specific cached data used internally for caching device features."""
34+
35+
1536
@dataclass
1637
class CacheData(RoborockBase):
1738
"""Data structure for caching device information."""
1839

1940
home_data: HomeData | None = None
2041
"""Home data containing device and product information."""
2142

43+
device_info: dict[str, DeviceCacheData] = field(default_factory=dict)
44+
"""Per-device cached information indexed by device DUID."""
45+
2246
network_info: dict[str, NetworkInfo] = field(default_factory=dict)
23-
"""Network information indexed by device DUID."""
47+
"""Network information indexed by device DUID.
48+
49+
This is deprecated. Use the per-device `network_info` field instead.
50+
"""
2451

2552
home_map_info: dict[int, CombinedMapInfo] = field(default_factory=dict)
26-
"""Home map information indexed by map_flag."""
53+
"""Home map information indexed by map_flag.
54+
55+
This is deprecated. Use the per-device `home_map_info` field instead.
56+
"""
2757

2858
home_map_content: dict[int, bytes] = field(default_factory=dict)
2959
"""Home cache content for each map data indexed by map_flag.
3060
31-
This is deprecated in favor of `home_map_content_base64`.
61+
This is deprecated. Use the per-device `home_map_content_base64` field instead.
3262
"""
3363

3464
home_map_content_base64: dict[int, str] = field(default_factory=dict)
35-
"""Home cache content for each map data (encoded base64) indexed by map_flag."""
65+
"""Home cache content for each map data (encoded base64) indexed by map_flag.
66+
67+
This is deprecated. Use the per-device `home_map_content_base64` field instead.
68+
"""
3669

3770
device_features: DeviceFeatures | None = None
38-
"""Device features information."""
71+
"""Device features information.
72+
73+
This is deprecated. Use the per-device `device_features` field instead.
74+
"""
3975

4076
trait_data: dict[str, Any] | None = None
41-
"""Trait-specific cached data used internally for caching device features."""
77+
"""Trait-specific cached data used internally for caching device features.
78+
79+
This is deprecated. Use the per-device `trait_data` field instead.
80+
"""
4281

4382

4483
class Cache(Protocol):

0 commit comments

Comments
 (0)