Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,50 @@ Install this via pip (or your favourite package manager):

You can see all of the commands supported [here]("https://python-roborock.readthedocs.io/en/latest/api_commands.html")

## Sending Commands

Here is an example that requires no manual intervention and can be done all automatically. You can skip some steps by
caching values or looking at them and grabbing them manually.
```python
import asyncio

from roborock import HomeDataProduct, DeviceData, RoborockCommand
from roborock.version_1_apis import RoborockMqttClientV1, RoborockLocalClientV1
from roborock.web_api import RoborockApiClient

async def main():
web_api = RoborockApiClient(username="youremailhere")
# Login via your password
user_data = await web_api.pass_login(password="pass_here")
# Or login via a code
await web_api.request_code()
code = input("What is the code?")
user_data = await web_api.code_login(code)

# Get home data
home_data = await web_api.get_home_data_v2(user_data)

# Get the device you want
device = home_data.devices[0]

# Get product ids:
product_info: dict[str, HomeDataProduct] = {
product.id: product for product in home_data.products
}
# Create the Mqtt(aka cloud required) Client
device_data = DeviceData(device, product_info[device.product_id].model)
mqtt_client = RoborockMqttClientV1(user_data, device_data)
networking = await mqtt_client.get_networking()
local_device_data = DeviceData(device, product_info[device.product_id].model, networking)
local_client = RoborockLocalClientV1(local_device_data)
# You can use the send_command to send any command to the device
status = await local_client.send_command(RoborockCommand.GET_STATUS)
# Or use existing functions that will give you data classes
status = await local_client.get_status()

asyncio.run(main())
```

## Supported devices

You can find what devices are supported
Expand Down
Loading