4343
4444from roborock import RoborockCommand
4545from roborock .data import RoborockBase , UserData
46+ from roborock .data .b01_q10 .b01_q10_code_mappings import B01_Q10_DP
4647from roborock .device_features import DeviceFeatures
4748from roborock .devices .cache import Cache , CacheData
4849from roborock .devices .device import RoborockDevice
@@ -745,6 +746,21 @@ async def network_info(ctx, device_id: str):
745746 await _display_v1_trait (context , device_id , lambda v1 : v1 .network_info )
746747
747748
749+ def _parse_b01_q10_command (cmd : str ) -> B01_Q10_DP :
750+ """Parse B01_Q10 command from either enum name or value."""
751+ try :
752+ return B01_Q10_DP (int (cmd ))
753+ except ValueError :
754+ try :
755+ return B01_Q10_DP .from_name (cmd )
756+ except ValueError :
757+ try :
758+ return B01_Q10_DP .from_value (cmd )
759+ except ValueError :
760+ pass
761+ raise RoborockException (f"Invalid command { cmd } for B01_Q10 device" )
762+
763+
748764@click .command ()
749765@click .option ("--device_id" , required = True )
750766@click .option ("--cmd" , required = True )
@@ -755,12 +771,18 @@ async def command(ctx, cmd, device_id, params):
755771 context : RoborockContext = ctx .obj
756772 device_manager = await context .get_device_manager ()
757773 device = await device_manager .get_device (device_id )
758- if device .v1_properties is None :
759- raise RoborockException (f"Device { device .name } does not support V1 protocol" )
760- command_trait : Trait = device .v1_properties .command
761- result = await command_trait .send (cmd , json .loads (params ) if params is not None else None )
762- if result :
763- click .echo (dump_json (result ))
774+ if device .v1_properties is not None :
775+ command_trait : Trait = device .v1_properties .command
776+ result = await command_trait .send (cmd , json .loads (params ) if params is not None else None )
777+ if result :
778+ click .echo (dump_json (result ))
779+ elif device .b01_q10_properties is not None :
780+ cmd_value = _parse_b01_q10_command (cmd )
781+ command_trait : Trait = device .b01_q10_properties .command
782+ await command_trait .send (cmd_value , json .loads (params ) if params is not None else None )
783+ click .echo ("Command sent successfully; Enable debug logging (-d) to see responses." )
784+ # Q10 commands don't have a specific time to respond, so wait a bit and log
785+ await asyncio .sleep (5 )
764786
765787
766788@click .command ()
0 commit comments