Skip to content

Commit 32abce5

Browse files
feat: add specific device functionality (#46)
* feat: add support for old mop and vacuum codes * fix: linting * fix: linting * feat: using api for single device and adding new commands * fix: using single device api (cherry picked from commit e689e8d) * chore: linting (cherry picked from commit 2ed367c) * chore: linting (cherry picked from commit 58b4683) * chore: linting * chore: linting * chore: init work * feat: added more device specific * fix: linting * fix: merge issues * feat: finalize specific device work * feat: finished specific device with current info * fix: add fast for S8 * fix: add s8 dock --------- Co-authored-by: humbertogontijo <[email protected]>
1 parent e3f2541 commit 32abce5

File tree

9 files changed

+467
-200
lines changed

9 files changed

+467
-200
lines changed

roborock/api.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from Crypto.Cipher import AES
2121
from Crypto.Util.Padding import unpad
2222

23-
from .code_mappings import RoborockDockTypeCode, RoborockEnum
23+
from .code_mappings import RoborockDockTypeCode
2424
from .containers import (
2525
CleanRecord,
2626
CleanSummary,
@@ -166,7 +166,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
166166

167167
def on_connection_lost(self, exc: Optional[Exception]) -> None:
168168
self._last_disconnection = self.time_func()
169-
_LOGGER.warning("Roborock client disconnected")
169+
_LOGGER.info("Roborock client disconnected")
170170
if exc is not None:
171171
_LOGGER.warning(exc)
172172

@@ -223,7 +223,10 @@ async def send_command(self, method: RoborockCommand, params: Optional[list | di
223223
async def get_status(self) -> Status | None:
224224
status = await self.send_command(RoborockCommand.GET_STATUS)
225225
if isinstance(status, dict):
226-
return Status.from_dict(status)
226+
status = Status.from_dict(status)
227+
status.update_status(self.device_info.model_specification)
228+
return status
229+
227230
return None
228231

229232
async def get_dnd_timer(self) -> DNDTimer | None:
@@ -294,7 +297,7 @@ async def get_smart_wash_params(self) -> SmartWashParams | None:
294297
_LOGGER.error(e)
295298
return None
296299

297-
async def get_dock_summary(self, dock_type: RoborockEnum) -> DockSummary | None:
300+
async def get_dock_summary(self, dock_type: RoborockDockTypeCode) -> DockSummary | None:
298301
"""Gets the status summary from the dock with the methods available for a given dock.
299302
300303
:param dock_type: RoborockDockTypeCode"""
@@ -306,7 +309,7 @@ async def get_dock_summary(self, dock_type: RoborockEnum) -> DockSummary | None:
306309
DustCollectionMode | WashTowelMode | SmartWashParams | None,
307310
]
308311
] = [self.get_dust_collection_mode()]
309-
if dock_type == RoborockDockTypeCode["3"]:
312+
if dock_type == RoborockDockTypeCode.empty_wash_fill_dock or dock_type == RoborockDockTypeCode.s8_dock:
310313
commands += [
311314
self.get_wash_towel_mode(),
312315
self.get_smart_wash_params(),
@@ -333,7 +336,7 @@ async def get_prop(self) -> DeviceProp | None:
333336
if clean_summary and clean_summary.records and len(clean_summary.records) > 0:
334337
last_clean_record = await self.get_clean_record(clean_summary.records[0])
335338
dock_summary = None
336-
if status and status.dock_type is not None and status.dock_type != RoborockDockTypeCode["0"]:
339+
if status and status.dock_type is not None and status.dock_type != RoborockDockTypeCode.no_dock:
337340
dock_summary = await self.get_dock_summary(status.dock_type)
338341
if any([status, dnd_timer, clean_summary, consumable]):
339342
return DeviceProp(

roborock/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ async def command(ctx, cmd, device_id, params):
121121
await _discover(ctx)
122122
login_data = context.login_data()
123123
home_data = login_data.home_data
124-
device = next((device for device in home_data.get_all_devices() if device.duid == device_id))
125-
device_info = RoborockDeviceInfo(device=device)
124+
devices = home_data.devices + home_data.received_devices
125+
device = next((device for device in devices if device.duid == device_id), None)
126+
model_specification = next(
127+
(product.model_specification for product in home_data.products if product.did == device.duid), None
128+
)
129+
device_info = RoborockDeviceInfo(device=device, model_specification=model_specification)
126130
mqtt_client = RoborockMqttClient(login_data.user_data, device_info)
127131
await mqtt_client.send_command(cmd, params)
128132
mqtt_client.__del__()

0 commit comments

Comments
 (0)