From 2d9c629eae06c8d77891b2f6d7f3fc01aa1a40d3 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 14 Sep 2023 13:08:02 -0400 Subject: [PATCH] fix: don't update status when it was none before listener --- roborock/api.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/roborock/api.py b/roborock/api.py index f7d7591..4dd3d9f 100644 --- a/roborock/api.py +++ b/roborock/api.py @@ -186,9 +186,7 @@ def __init__(self, endpoint: str, device_info: DeviceData, queue_timeout: int = self._listeners: list[Callable[[str, CacheableAttribute, RoborockBase], None]] = [] self.is_available: bool = True self.queue_timeout = queue_timeout - self._status_type: type[Status] = ModelStatus.get( - self.device_info.model, S7MaxVStatus - ) + self._status_type: type[Status] = ModelStatus.get(self.device_info.model, S7MaxVStatus) def __del__(self) -> None: self.release() @@ -265,7 +263,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None: self._logger.debug( f"Got status update({data_protocol.name}) before get_status was called." ) - self.cache[CacheableAttribute.status]._value = {} + return value = self.cache[CacheableAttribute.status].value value[data_protocol.name] = data_point status = self._status_type.from_dict(value) @@ -277,7 +275,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None: f"Got consumable update({data_protocol.name})" + "before get_consumable was called." ) - self.cache[CacheableAttribute.consumable]._value = {} + return value = self.cache[CacheableAttribute.consumable].value value[data_protocol.name] = data_point consumable = Consumable.from_dict(value)