@@ -20,6 +20,50 @@ Install this via pip (or your favourite package manager):
20
20
21
21
You can see all of the commands supported [ here] ( "https://python-roborock.readthedocs.io/en/latest/api_commands.html" )
22
22
23
+ ## Sending Commands
24
+
25
+ Here is an example that requires no manual intervention and can be done all automatically. You can skip some steps by
26
+ caching values or looking at them and grabbing them manually.
27
+ ``` python
28
+ import asyncio
29
+
30
+ from roborock import HomeDataProduct, DeviceData, RoborockCommand
31
+ from roborock.version_1_apis import RoborockMqttClientV1, RoborockLocalClientV1
32
+ from roborock.web_api import RoborockApiClient
33
+
34
+ async def main ():
35
+ web_api = RoborockApiClient(username = " youremailhere" )
36
+ # Login via your password
37
+ user_data = await web_api.pass_login(password = " pass_here" )
38
+ # Or login via a code
39
+ await web_api.request_code()
40
+ code = input (" What is the code?" )
41
+ user_data = await web_api.code_login(code)
42
+
43
+ # Get home data
44
+ home_data = await web_api.get_home_data_v2(user_data)
45
+
46
+ # Get the device you want
47
+ device = home_data.devices[0 ]
48
+
49
+ # Get product ids:
50
+ product_info: dict[str , HomeDataProduct] = {
51
+ product.id: product for product in home_data.products
52
+ }
53
+ # Create the Mqtt(aka cloud required) Client
54
+ device_data = DeviceData(device, product_info[device.product_id].model)
55
+ mqtt_client = RoborockMqttClientV1(user_data, device_data)
56
+ networking = await mqtt_client.get_networking()
57
+ local_device_data = DeviceData(device, product_info[device.product_id].model, networking)
58
+ local_client = RoborockLocalClientV1(local_device_data)
59
+ # You can use the send_command to send any command to the device
60
+ status = await local_client.send_command(RoborockCommand.GET_STATUS )
61
+ # Or use existing functions that will give you data classes
62
+ status = await local_client.get_status()
63
+
64
+ asyncio.run(main())
65
+ ```
66
+
23
67
## Supported devices
24
68
25
69
You can find what devices are supported
0 commit comments