Skip to content

Commit 59ef6f4

Browse files
authored
feat: add diagnostic data and extra containers (#67)
* feat: add diagnostic data and extra containers * fix: lint * fix: dock summary as roborockbase * fix: make deviceprop RoborockBase * merge in changes * fix: lint
1 parent 22ff7f4 commit 59ef6f4

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

roborock/api.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
DeviceData,
2727
DnDTimer,
2828
DustCollectionMode,
29+
FlowLedStatus,
2930
HomeData,
3031
ModelStatus,
3132
MultiMapsList,
@@ -101,10 +102,15 @@ def __init__(self, endpoint: str, device_info: DeviceData) -> None:
101102
self._last_device_msg_in = self.time_func()
102103
self._last_disconnection = self.time_func()
103104
self.keep_alive = KEEPALIVE
105+
self._diagnostic_data: dict[str, dict[str, Any]] = {}
104106

105107
def __del__(self) -> None:
106108
self.sync_disconnect()
107109

110+
@property
111+
def diagnostic_data(self) -> dict:
112+
return self._diagnostic_data
113+
108114
@property
109115
def time_func(self) -> Callable[[], float]:
110116
try:
@@ -364,6 +370,11 @@ async def get_child_lock_status(self) -> ChildLockStatus | None:
364370
"""Gets current child lock status."""
365371
return await self.send_command(RoborockCommand.GET_CHILD_LOCK_STATUS, return_type=ChildLockStatus)
366372

373+
@fallback_cache
374+
async def get_flow_led_status(self) -> FlowLedStatus | None:
375+
"""Gets current flow led status."""
376+
return await self.send_command(RoborockCommand.GET_FLOW_LED_STATUS, return_type=FlowLedStatus)
377+
367378
@fallback_cache
368379
async def get_sound_volume(self) -> int | None:
369380
"""Gets current volume level."""

roborock/cloud_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ async def send_command(
165165
msg = MessageParser.build(roborock_message, local_key, False)
166166
self._send_msg_raw(msg)
167167
(response, err) = await self._async_response(request_id, response_protocol)
168+
self._diagnostic_data[method.name] = {"params": params, "response": response, "error": err}
168169
if err:
169170
raise CommandVacuumError(method, err) from err
170171
if response_protocol == 301:

roborock/containers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ class ChildLockStatus(RoborockBase):
505505
lock_status: int
506506

507507

508+
@dataclass
509+
class FlowLedStatus(RoborockBase):
510+
status: int
511+
512+
508513
@dataclass
509514
class BroadcastMessage(RoborockBase):
510515
duid: str

roborock/local_api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ async def async_local_response(self, roborock_message: RoborockMessage):
147147
if request_id is None:
148148
raise RoborockException(f"Failed build message {roborock_message}")
149149
(response, err) = await self._async_response(request_id, response_protocol)
150+
self._diagnostic_data[method if method is not None else "unknown"] = {
151+
"params": roborock_message.get_params(),
152+
"response": response,
153+
"error": err,
154+
}
150155
if err:
151156
raise CommandVacuumError("", err) from err
152157
if roborock_message.protocol == 4:

roborock/roborock_typing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Consumable,
1111
DnDTimer,
1212
DustCollectionMode,
13+
RoborockBase,
1314
SmartWashParams,
1415
Status,
1516
WashTowelMode,
@@ -301,14 +302,14 @@ class CommandInfo:
301302

302303

303304
@dataclass
304-
class DockSummary:
305+
class DockSummary(RoborockBase):
305306
dust_collection_mode: Optional[DustCollectionMode] = None
306307
wash_towel_mode: Optional[WashTowelMode] = None
307308
smart_wash_params: Optional[SmartWashParams] = None
308309

309310

310311
@dataclass
311-
class DeviceProp:
312+
class DeviceProp(RoborockBase):
312313
status: Optional[Status] = None
313314
dnd_timer: Optional[DnDTimer] = None
314315
clean_summary: Optional[CleanSummary] = None

0 commit comments

Comments
 (0)