Roborock library for online and offline control of your vacuums.
Install this via pip (or your favourite package manager):
pip install python-roborock
You can see all of the commands supported here
import asyncio
from roborock.web_api import RoborockApiClient
from roborock.devices.device_manager import create_device_manager, UserParams
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)
# Create a device manager that can discover devices.
user_params = UserParams(
username="youremailhere",
user_data=user_data,
)
device_manager = await create_device_manager(user_params)
devices = await device_manager.get_devices()
# Get all vacuum devices that support the v1 PropertiesApi
for device in devices:
if not device.v1_properties:
continue
# Refresh the current device status
status_trait = device.v1_properties.status
await status_trait.refresh()
print(status_trait)
asyncio.run(main())See examples/example.py for a more full featured example that has performance improvements to cache cloud information to prefer connections over the local network.
You can find what devices are supported here. Please note this may not immediately contain the latest devices.
Thanks @rovo89 for https://gist.github.com/rovo89/dff47ed19fca0dfdda77503e66c2b7c7 And thanks @PiotrMachowski for https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor