Skip to content

Commit 2035af5

Browse files
authored
fix: remove dnd timer and valley electricity from props (#75)
* fix: remove dnd timer and valley electricity from props * fix: linting * fix: clear out old keep alive before adding new one * chore: remove keep_alive_task * fix: add storing of dnd and valley in api
1 parent 74ced28 commit 2035af5

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

roborock/api.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ def __init__(self, endpoint: str, device_info: DeviceData) -> None:
103103
self._last_disconnection = self.time_func()
104104
self.keep_alive = KEEPALIVE
105105
self._diagnostic_data: dict[str, dict[str, Any]] = {}
106+
self.dnd_timer: DnDTimer | None = None
107+
self.valley_timer: ValleyElectricityTimer | None = None
106108

107109
def __del__(self) -> None:
108110
self.sync_disconnect()
@@ -255,11 +257,19 @@ async def get_status(self) -> Status | None:
255257

256258
@fallback_cache
257259
async def get_dnd_timer(self) -> DnDTimer | None:
258-
return await self.send_command(RoborockCommand.GET_DND_TIMER, return_type=DnDTimer)
260+
result = await self.send_command(RoborockCommand.GET_DND_TIMER, return_type=DnDTimer)
261+
if result is not None:
262+
self.dnd_timer = result
263+
return result
259264

260265
@fallback_cache
261266
async def get_valley_electricity_timer(self) -> ValleyElectricityTimer | None:
262-
return await self.send_command(RoborockCommand.GET_VALLEY_ELECTRICITY_TIMER, return_type=ValleyElectricityTimer)
267+
result = await self.send_command(
268+
RoborockCommand.GET_VALLEY_ELECTRICITY_TIMER, return_type=ValleyElectricityTimer
269+
)
270+
if result is not None:
271+
self.valley_timer = result
272+
return result
263273

264274
@fallback_cache
265275
async def get_clean_summary(self) -> CleanSummary | None:
@@ -323,13 +333,11 @@ async def get_dock_summary(self, dock_type: RoborockDockTypeCode) -> DockSummary
323333
@fallback_cache
324334
async def get_prop(self) -> DeviceProp | None:
325335
"""Gets device general properties."""
326-
[status, clean_summary, consumable, dnd_timer, valley_electricity_timer] = await asyncio.gather(
336+
[status, clean_summary, consumable] = await asyncio.gather(
327337
*[
328338
self.get_status(),
329339
self.get_clean_summary(),
330340
self.get_consumable(),
331-
self.get_dnd_timer(),
332-
self.get_valley_electricity_timer(),
333341
]
334342
)
335343
last_clean_record = None
@@ -338,13 +346,11 @@ async def get_prop(self) -> DeviceProp | None:
338346
dock_summary = None
339347
if status and status.dock_type is not None and status.dock_type != RoborockDockTypeCode.no_dock:
340348
dock_summary = await self.get_dock_summary(status.dock_type)
341-
if any([status, dnd_timer, clean_summary, consumable]):
349+
if any([status, clean_summary, consumable]):
342350
return DeviceProp(
343351
status,
344352
clean_summary,
345353
consumable,
346-
dnd_timer,
347-
valley_electricity_timer,
348354
last_clean_record,
349355
dock_summary,
350356
)

roborock/roborock_typing.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
CleanRecord,
99
CleanSummary,
1010
Consumable,
11-
DnDTimer,
1211
DustCollectionMode,
1312
RoborockBase,
1413
SmartWashParams,
1514
Status,
16-
ValleyElectricityTimer,
1715
WashTowelMode,
1816
)
1917

@@ -314,8 +312,6 @@ class DeviceProp(RoborockBase):
314312
status: Optional[Status] = None
315313
clean_summary: Optional[CleanSummary] = None
316314
consumable: Optional[Consumable] = None
317-
dnd_timer: Optional[DnDTimer] = None
318-
valley_electricity_timer: Optional[ValleyElectricityTimer] = None
319315
last_clean_record: Optional[CleanRecord] = None
320316
dock_summary: Optional[DockSummary] = None
321317

@@ -326,10 +322,6 @@ def update(self, device_prop: DeviceProp) -> None:
326322
self.clean_summary = device_prop.clean_summary
327323
if device_prop.consumable:
328324
self.consumable = device_prop.consumable
329-
if device_prop.dnd_timer:
330-
self.dnd_timer = device_prop.dnd_timer
331-
if device_prop.valley_electricity_timer:
332-
self.valley_electricity_timer = device_prop.valley_electricity_timer
333325
if device_prop.last_clean_record:
334326
self.last_clean_record = device_prop.last_clean_record
335327
if device_prop.dock_summary:

0 commit comments

Comments
 (0)