Skip to content

Commit 1574803

Browse files
committed
add scenes support
1 parent da65579 commit 1574803

File tree

2 files changed

+78
-4
lines changed

2 files changed

+78
-4
lines changed

roborock/web_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ async def get_rooms(self, user_data: UserData, home_id: int | None = None) -> li
269269
else:
270270
raise RoborockException("home_response result was an unexpected type")
271271

272-
async def get_scenes(self, user_data: UserData, home_id: int) -> list[HomeDataScene]:
272+
async def get_scenes(self, user_data: UserData, device_id: int) -> list[HomeDataScene]:
273273
rriot = user_data.rriot
274274
if rriot is None:
275275
raise RoborockException("rriot is none")
@@ -278,10 +278,10 @@ async def get_scenes(self, user_data: UserData, home_id: int) -> list[HomeDataSc
278278
scenes_request = PreparedRequest(
279279
rriot.r.a,
280280
{
281-
"Authorization": self._get_hawk_authentication(rriot, f"/user/scene/device/{str(home_id)}"),
281+
"Authorization": self._get_hawk_authentication(rriot, f"/user/scene/device/{str(device_id)}"),
282282
},
283283
)
284-
scenes_response = await scenes_request.request("get", f"/user/scene/device/{str(home_id)}")
284+
scenes_response = await scenes_request.request("get", f"/user/scene/device/{str(device_id)}")
285285
if not scenes_response.get("success"):
286286
raise RoborockException(scenes_response)
287287
scenes = scenes_response.get("result")

tests/mock_data.py

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Mock data for Roborock tests."""
22

33
import hashlib
4+
import json
45

56
# All data is based on a U.S. customer with a Roborock S7 MaxV Ultra
67
USER_EMAIL = "user@domain.com"
@@ -39,7 +40,80 @@
3940
{
4041
"id": 5925425,
4142
"name": "My plan",
42-
"param": "not used",
43+
"param": json.dumps(
44+
{
45+
"triggers": [],
46+
"action": {
47+
"type": "S",
48+
"items": [
49+
{
50+
"id": 5,
51+
"type": "CMD",
52+
"name": "",
53+
"entityId": "1C3LfIPN9fLI0vV3dmJe3E",
54+
"param": json.dumps(
55+
{
56+
"id": 5,
57+
"method": "do_scenes_app_start",
58+
"params": [
59+
{
60+
"fan_power": 104,
61+
"water_box_mode": 200,
62+
"mop_mode": 300,
63+
"mop_template_id": 300,
64+
"repeat": 1,
65+
"auto_dustCollection": 1,
66+
"source": 101,
67+
}
68+
],
69+
}
70+
),
71+
"finishDpIds": [130],
72+
},
73+
{
74+
"id": 4,
75+
"type": "CMD",
76+
"name": "Study Living room Dining room Bedroom Hall",
77+
"entityId": "1C3LfIPN9fLI0vV3dmJe3E",
78+
"param": json.dumps(
79+
{
80+
"id": 4,
81+
"method": "do_scenes_segments",
82+
"params": {
83+
"data": [
84+
{
85+
"tid": "1738240000786",
86+
"segs": [
87+
{"sid": 19},
88+
{"sid": 18},
89+
{"sid": 22},
90+
{"sid": 21},
91+
{"sid": 16},
92+
],
93+
"map_flag": 0,
94+
"fan_power": 105,
95+
"water_box_mode": 201,
96+
"mop_mode": 300,
97+
"mop_template_id": 300,
98+
"repeat": 1,
99+
"clean_order_mode": 1,
100+
"auto_dry": 1,
101+
"auto_dustCollection": 1,
102+
"region_num": 0,
103+
}
104+
],
105+
"source": 101,
106+
},
107+
}
108+
),
109+
"finishDpIds": [130],
110+
},
111+
],
112+
},
113+
"matchType": "NONE",
114+
"tagId": "1002",
115+
}
116+
),
43117
"enabled": True,
44118
"extra": None,
45119
"type": "WORKFLOW",

0 commit comments

Comments
 (0)