Skip to content

Commit 1286b9b

Browse files
committed
chore: Simplify command sending
1 parent 8e9f1ba commit 1286b9b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

roborock/devices/traits/dnd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ class DoNotDisturbTrait(Trait):
2727

2828
def __init__(self, rpc_channel: Callable[[], V1RpcChannel]) -> None:
2929
"""Initialize the DoNotDisturbTrait."""
30-
self._rpc_channel = rpc_channel
30+
self._send_command = lambda *args, **kwargs: rpc_channel().send_command(*args, **kwargs)
3131

3232
async def get_dnd_timer(self) -> DnDTimer:
3333
"""Get the current Do Not Disturb (DND) timer settings of the device."""
34-
return await self._rpc_channel().send_command(RoborockCommand.GET_DND_TIMER, response_type=DnDTimer)
34+
return await self._send_command(RoborockCommand.GET_DND_TIMER, response_type=DnDTimer)
3535

3636
async def set_dnd_timer(self, dnd_timer: DnDTimer) -> None:
3737
"""Set the Do Not Disturb (DND) timer settings of the device."""
38-
await self._rpc_channel().send_command(RoborockCommand.SET_DND_TIMER, params=dnd_timer.as_dict())
38+
await self._send_command(RoborockCommand.SET_DND_TIMER, params=dnd_timer.as_dict())
3939

4040
async def clear_dnd_timer(self) -> None:
4141
"""Clear the Do Not Disturb (DND) timer settings of the device."""
42-
await self._rpc_channel().send_command(RoborockCommand.CLOSE_DND_TIMER)
42+
await self._send_command(RoborockCommand.CLOSE_DND_TIMER)

roborock/devices/traits/status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class StatusTrait(Trait):
3333
def __init__(self, product_info: HomeDataProduct, rpc_channel: Callable[[], V1RpcChannel]) -> None:
3434
"""Initialize the StatusTrait."""
3535
self._product_info = product_info
36-
self._rpc_channel = rpc_channel
36+
self._send_command = lambda *args, **kwargs: rpc_channel().send_command(*args, **kwargs)
3737

3838
async def get_status(self) -> Status:
3939
"""Get the current status of the device.
4040
4141
This is a placeholder command and will likely be changed/moved in the future.
4242
"""
4343
status_type: type[Status] = ModelStatus.get(self._product_info.model, S7MaxVStatus)
44-
return await self._rpc_channel().send_command(RoborockCommand.GET_STATUS, response_type=status_type)
44+
return await self._send_command(RoborockCommand.GET_STATUS, response_type=status_type)

0 commit comments

Comments
 (0)