@@ -184,12 +184,18 @@ def __init__(self, endpoint: str, device_info: DeviceData, queue_timeout: int =
184184 device_cache [device_info .device .duid ] = cache
185185 self .cache : dict [CacheableAttribute , AttributeCache ] = cache
186186 self ._listeners : list [Callable [[str , CacheableAttribute , RoborockBase ], None ]] = []
187- self .is_available : bool = False
187+ self .is_available : bool = True
188188 self .queue_timeout = queue_timeout
189+ self ._status_type : type [Status ] = ModelStatus .get (self .device_info .model , S7MaxVStatus )
189190
190191 def __del__ (self ) -> None :
191192 self .release ()
192193
194+ @property
195+ def status_type (self ) -> type [Status ]:
196+ """Gets the status type for this device"""
197+ return self ._status_type
198+
193199 def release (self ):
194200 self .sync_disconnect ()
195201 [item .stop () for item in self .cache .values ()]
@@ -253,17 +259,14 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
253259 data_protocol = RoborockDataProtocol (int (data_point_number ))
254260 self ._logger .debug (f"Got device update for { data_protocol .name } : { data_point } " )
255261 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
259262 if self .cache [CacheableAttribute .status ].value is None :
260263 self ._logger .debug (
261264 f"Got status update({ data_protocol .name } ) before get_status was called."
262265 )
263- self . cache [ CacheableAttribute . status ]. _value = {}
266+ return
264267 value = self .cache [CacheableAttribute .status ].value
265268 value [data_protocol .name ] = data_point
266- status = _cls .from_dict (value )
269+ status = self . _status_type .from_dict (value )
267270 for listener in self ._listeners :
268271 listener (self .device_info .device .duid , CacheableAttribute .status , status )
269272 elif data_protocol in ROBOROCK_DATA_CONSUMABLE_PROTOCOL :
@@ -272,7 +275,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
272275 f"Got consumable update({ data_protocol .name } )"
273276 + "before get_consumable was called."
274277 )
275- self . cache [ CacheableAttribute . consumable ]. _value = {}
278+ return
276279 value = self .cache [CacheableAttribute .consumable ].value
277280 value [data_protocol .name ] = data_point
278281 consumable = Consumable .from_dict (value )
@@ -406,10 +409,7 @@ async def send_command(
406409 return response
407410
408411 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 ())
413413
414414 async def get_dnd_timer (self ) -> DnDTimer | None :
415415 return DnDTimer .from_dict (await self .cache [CacheableAttribute .dnd_timer ].async_value ())
0 commit comments