-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathstatus.py
More file actions
24 lines (18 loc) · 986 Bytes
/
status.py
File metadata and controls
24 lines (18 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Self
from roborock.containers import HomeDataProduct, Status, get_custom_status
from roborock.devices.traits.v1 import common
from roborock.roborock_typing import RoborockCommand
class StatusTrait(Status, common.V1TraitMixin):
"""Trait for managing the status of Roborock devices."""
command = RoborockCommand.GET_STATUS
def __init__(self, product_info: HomeDataProduct) -> None:
"""Initialize the StatusTrait."""
self._product_info = product_info
self._status_type = get_custom_status(self.device_info.device_features, self.device_info.region)
def _parse_response(self, response: common.V1ResponseData) -> Self:
"""Parse the response from the device into a CleanSummary."""
if isinstance(response, list):
response = response[0]
if isinstance(response, dict):
return self._status_type.from_dict(response)
raise ValueError(f"Unexpected status format: {response!r}")