Skip to content

Commit 0101b4d

Browse files
committed
Update documentation to point to the newer device APIs
1 parent 20afa92 commit 0101b4d

File tree

7 files changed

+57
-53
lines changed

7 files changed

+57
-53
lines changed

README.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ You can see all of the commands supported [here](https://python-roborock.readthe
2424

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

30-
from roborock import HomeDataProduct, DeviceData, RoborockCommand
31-
from roborock.version_1_apis import RoborockMqttClientV1, RoborockLocalClientV1
3231
from roborock.web_api import RoborockApiClient
32+
from roborock.devices.device_manager import create_device_manager, UserParams
33+
3334

3435
async def main():
3536
web_api = RoborockApiClient(username="youremailhere")
@@ -40,26 +41,23 @@ async def main():
4041
code = input("What is the code?")
4142
user_data = await web_api.code_login(code)
4243

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.ip)
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()
44+
# Create a device manager that can discover devices.
45+
user_params = UserParams(
46+
username="youremailhere",
47+
user_data=user_data,
48+
)
49+
device_manager = await create_device_manager(user_params)
50+
devices = await device_manager.get_devices()
51+
52+
# Get all vacuum devices that support the v1 PropertiesApi
53+
for device in devices:
54+
if not device.v1_properties:
55+
continue
56+
57+
# Refresh the current device status
58+
status_trait = device.v1_properties.status
59+
await status_trait.refresh()
60+
print(status_trait)
6361

6462
asyncio.run(main())
6563
```

roborock/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
cloud_api,
1212
const,
1313
data,
14+
devices,
1415
exceptions,
1516
roborock_typing,
1617
version_1_apis,
@@ -19,13 +20,11 @@
1920
)
2021

2122
__all__ = [
23+
"devices",
24+
"data",
25+
"map",
2226
"web_api",
23-
"version_1_apis",
24-
"version_a01_apis",
25-
"const",
26-
"cloud_api",
2727
"roborock_typing",
2828
"exceptions",
29-
"data",
30-
# Add new APIs here in the future when they are public e.g. devices/
29+
"const",
3130
]

roborock/devices/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Roborock Device Discovery
1+
# Roborock Devices & Discovery
22

3-
This page documents the full lifecycle of device discovery across Cloud and Network.
3+
The devices module provides functionality to discover Roborock devices on the
4+
network. This section documents the full lifecycle of device discovery across
5+
Cloud and Network.
46

57
## Init account setup
68

@@ -61,7 +63,7 @@ that a newer version of the API should be used.
6163

6264
## Design
6365

64-
### Current API Issues
66+
### Prior API Issues
6567

6668
- Complex Inheritance Hierarchy: Multiple inheritance with classes like RoborockMqttClientV1 inheriting from both RoborockMqttClient and RoborockClientV1
6769

roborock/devices/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
"""The devices module provides functionality to discover Roborock devices on the network."""
1+
"""
2+
.. include:: ./README.md
3+
"""
24

35
__all__ = [
46
"device",
57
"device_manager",
68
"cache",
9+
"traits",
710
]

roborock/devices/traits/b01/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from roborock.roborock_message import RoborockB01Props
88

99
__init__ = [
10-
"create_b01_traits",
1110
"PropertiesApi",
1211
]
1312

roborock/devices/traits/v1/__init__.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,27 @@
6767
_LOGGER = logging.getLogger(__name__)
6868

6969
__all__ = [
70-
"create",
7170
"PropertiesApi",
72-
"StatusTrait",
73-
"DoNotDisturbTrait",
74-
"CleanSummaryTrait",
75-
"SoundVolumeTrait",
76-
"MapsTrait",
77-
"MapContentTrait",
78-
"ConsumableTrait",
79-
"HomeTrait",
80-
"DeviceFeaturesTrait",
81-
"CommandTrait",
82-
"ChildLockTrait",
83-
"FlowLedStatusTrait",
84-
"LedStatusTrait",
85-
"ValleyElectricityTimerTrait",
86-
"DustCollectionModeTrait",
87-
"WashTowelModeTrait",
88-
"SmartWashParamsTrait",
89-
"NetworkInfoTrait",
90-
"RoutinesTrait",
71+
"child_lock",
72+
"clean_summary",
73+
"common",
74+
"consumable",
75+
"device_features",
76+
"do_not_disturb",
77+
"dust_collection_mode",
78+
"flow_led_status",
79+
"home",
80+
"led_status",
81+
"map_content",
82+
"maps",
83+
"network_info",
84+
"rooms",
85+
"routines",
86+
"smart_wash_params",
87+
"status",
88+
"valley_electricity_timer",
89+
"volume",
90+
"wash_towel_mode",
9191
]
9292

9393

roborock/protocols/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Protocols for communicating with Roborock devices."""
2+
3+
__all__: list[str] = []

0 commit comments

Comments
 (0)