Skip to content

Commit

Permalink
fix: don't update status when it was none before listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Lash-L committed Sep 14, 2023
1 parent eb0bd94 commit 2d9c629
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions roborock/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 2d9c629

Please sign in to comment.