Skip to content

Commit 6f4b506

Browse files
committed
fix(q10): Use correct B01 Q10 properties API
- Change from device.traits.get('VacuumTrait') to device.b01_q10_properties.vacuum - Fix AttributeError that would occur at runtime - Update error messages to reflect B01 Q10 protocol requirement - Addresses code review feedback from copilot-pull-request-reviewer
1 parent 2cf5bd1 commit 6f4b506

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

roborock/cli.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,9 @@ async def _q10_vacuum_trait(context: RoborockContext, device_id: str):
442442
"""Get VacuumTrait from Q10 device."""
443443
device_manager = await context.get_device_manager()
444444
device = await device_manager.get_device(device_id)
445-
trait = device.traits.get("VacuumTrait")
446-
if not trait:
447-
raise RoborockUnsupportedFeature("Device does not have VacuumTrait. Is it a Q10?")
448-
return trait
445+
if device.b01_q10_properties is None:
446+
raise RoborockUnsupportedFeature("Device does not support B01 Q10 protocol. Is it a Q10?")
447+
return device.b01_q10_properties.vacuum
449448

450449

451450
@session.command()
@@ -1163,7 +1162,7 @@ async def q10_vacuum_start(ctx, device_id):
11631162
await trait.start_clean()
11641163
click.echo("Starting vacuum cleaning...")
11651164
except RoborockUnsupportedFeature:
1166-
click.echo("Device does not have VacuumTrait. Is it a Q10?")
1165+
click.echo("Device does not support B01 Q10 protocol. Is it a Q10?")
11671166
except RoborockException as e:
11681167
click.echo(f"Error: {e}")
11691168

@@ -1180,7 +1179,7 @@ async def q10_vacuum_pause(ctx, device_id):
11801179
await trait.pause_clean()
11811180
click.echo("Pausing vacuum cleaning...")
11821181
except RoborockUnsupportedFeature:
1183-
click.echo("Device does not have VacuumTrait. Is it a Q10?")
1182+
click.echo("Device does not support B01 Q10 protocol. Is it a Q10?")
11841183
except RoborockException as e:
11851184
click.echo(f"Error: {e}")
11861185

@@ -1197,7 +1196,7 @@ async def q10_vacuum_resume(ctx, device_id):
11971196
await trait.resume_clean()
11981197
click.echo("Resuming vacuum cleaning...")
11991198
except RoborockUnsupportedFeature:
1200-
click.echo("Device does not have VacuumTrait. Is it a Q10?")
1199+
click.echo("Device does not support B01 Q10 protocol. Is it a Q10?")
12011200
except RoborockException as e:
12021201
click.echo(f"Error: {e}")
12031202

@@ -1214,7 +1213,7 @@ async def q10_vacuum_stop(ctx, device_id):
12141213
await trait.stop_clean()
12151214
click.echo("Stopping vacuum cleaning...")
12161215
except RoborockUnsupportedFeature:
1217-
click.echo("Device does not have VacuumTrait. Is it a Q10?")
1216+
click.echo("Device does not support B01 Q10 protocol. Is it a Q10?")
12181217
except RoborockException as e:
12191218
click.echo(f"Error: {e}")
12201219

@@ -1231,7 +1230,7 @@ async def q10_vacuum_dock(ctx, device_id):
12311230
await trait.return_to_dock()
12321231
click.echo("Returning vacuum to dock...")
12331232
except RoborockUnsupportedFeature:
1234-
click.echo("Device does not have VacuumTrait. Is it a Q10?")
1233+
click.echo("Device does not support B01 Q10 protocol. Is it a Q10?")
12351234
except RoborockException as e:
12361235
click.echo(f"Error: {e}")
12371236

0 commit comments

Comments
 (0)