@@ -18,7 +18,7 @@ class DeviceCacheData(RoborockBase):
1818 """Data structure for caching device information."""
1919
2020 network_info : NetworkInfo | None = None
21- """Network information indexed by device DUID. """
21+ """Network information for the device"""
2222
2323 home_map_info : CombinedMapInfo | None = None
2424 """Home map information for the device."""
@@ -45,13 +45,13 @@ class CacheData(RoborockBase):
4545
4646 network_info : dict [str , NetworkInfo ] = field (default_factory = dict )
4747 """Network information indexed by device DUID.
48-
48+
4949 This is deprecated. Use the per-device `network_info` field instead.
5050 """
5151
5252 home_map_info : dict [int , CombinedMapInfo ] = field (default_factory = dict )
5353 """Home map information indexed by map_flag.
54-
54+
5555 This is deprecated. Use the per-device `home_map_info` field instead.
5656 """
5757
@@ -63,19 +63,19 @@ class CacheData(RoborockBase):
6363
6464 home_map_content_base64 : dict [int , str ] = field (default_factory = dict )
6565 """Home cache content for each map data (encoded base64) indexed by map_flag.
66-
66+
6767 This is deprecated. Use the per-device `home_map_content_base64` field instead.
6868 """
6969
7070 device_features : DeviceFeatures | None = None
7171 """Device features information.
72-
72+
7373 This is deprecated. Use the per-device `device_features` field instead.
7474 """
7575
7676 trait_data : dict [str , Any ] | None = None
7777 """Trait-specific cached data used internally for caching device features.
78-
78+
7979 This is deprecated. Use the per-device `trait_data` field instead.
8080 """
8181
@@ -91,6 +91,20 @@ async def set(self, value: CacheData) -> None:
9191 """Set value in the cache."""
9292 ...
9393
94+ async def get_device_info (self , duid : str ) -> DeviceCacheData :
95+ """Get cached device-specific information."""
96+ cache_data = await self .get ()
97+ if duid not in cache_data .device_info :
98+ cache_data .device_info [duid ] = DeviceCacheData ()
99+ await self .set (cache_data )
100+ return cache_data .device_info [duid ]
101+
102+ async def set_device_info (self , duid : str , device_cache_data : DeviceCacheData ) -> None :
103+ """Set cached device-specific information."""
104+ cache_data = await self .get ()
105+ cache_data .device_info [duid ] = device_cache_data
106+ await self .set (cache_data )
107+
94108
95109class InMemoryCache (Cache ):
96110 """In-memory cache implementation."""
0 commit comments