@@ -184,12 +184,18 @@ def __init__(self, endpoint: str, device_info: DeviceData, queue_timeout: int =
184
184
device_cache [device_info .device .duid ] = cache
185
185
self .cache : dict [CacheableAttribute , AttributeCache ] = cache
186
186
self ._listeners : list [Callable [[str , CacheableAttribute , RoborockBase ], None ]] = []
187
- self .is_available : bool = False
187
+ self .is_available : bool = True
188
188
self .queue_timeout = queue_timeout
189
+ self ._status_type : type [Status ] = ModelStatus .get (self .device_info .model , S7MaxVStatus )
189
190
190
191
def __del__ (self ) -> None :
191
192
self .release ()
192
193
194
+ @property
195
+ def status_type (self ) -> type [Status ]:
196
+ """Gets the status type for this device"""
197
+ return self ._status_type
198
+
193
199
def release (self ):
194
200
self .sync_disconnect ()
195
201
[item .stop () for item in self .cache .values ()]
@@ -253,17 +259,14 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
253
259
data_protocol = RoborockDataProtocol (int (data_point_number ))
254
260
self ._logger .debug (f"Got device update for { data_protocol .name } : { data_point } " )
255
261
if data_protocol in ROBOROCK_DATA_STATUS_PROTOCOL :
256
- _cls : type [Status ] = ModelStatus .get (
257
- self .device_info .model , S7MaxVStatus
258
- ) # Default to S7 MAXV if we don't have the data
259
262
if self .cache [CacheableAttribute .status ].value is None :
260
263
self ._logger .debug (
261
264
f"Got status update({ data_protocol .name } ) before get_status was called."
262
265
)
263
- self . cache [ CacheableAttribute . status ]. _value = {}
266
+ return
264
267
value = self .cache [CacheableAttribute .status ].value
265
268
value [data_protocol .name ] = data_point
266
- status = _cls .from_dict (value )
269
+ status = self . _status_type .from_dict (value )
267
270
for listener in self ._listeners :
268
271
listener (self .device_info .device .duid , CacheableAttribute .status , status )
269
272
elif data_protocol in ROBOROCK_DATA_CONSUMABLE_PROTOCOL :
@@ -272,7 +275,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
272
275
f"Got consumable update({ data_protocol .name } )"
273
276
+ "before get_consumable was called."
274
277
)
275
- self . cache [ CacheableAttribute . consumable ]. _value = {}
278
+ return
276
279
value = self .cache [CacheableAttribute .consumable ].value
277
280
value [data_protocol .name ] = data_point
278
281
consumable = Consumable .from_dict (value )
@@ -406,10 +409,7 @@ async def send_command(
406
409
return response
407
410
408
411
async def get_status (self ) -> Status | None :
409
- _cls : type [Status ] = ModelStatus .get (
410
- self .device_info .model , S7MaxVStatus
411
- ) # Default to S7 MAXV if we don't have the data
412
- return _cls .from_dict (await self .cache [CacheableAttribute .status ].async_value ())
412
+ return self ._status_type .from_dict (await self .cache [CacheableAttribute .status ].async_value ())
413
413
414
414
async def get_dnd_timer (self ) -> DnDTimer | None :
415
415
return DnDTimer .from_dict (await self .cache [CacheableAttribute .dnd_timer ].async_value ())
0 commit comments