|
14 | 14 | from aiohttp import ContentTypeError, FormData |
15 | 15 | from pyrate_limiter import BucketFullException, Duration, Limiter, Rate |
16 | 16 |
|
| 17 | +from roborock import HomeDataSchedule |
17 | 18 | from roborock.data import HomeData, HomeDataRoom, HomeDataScene, ProductResponse, RRiot, UserData |
18 | 19 | from roborock.exceptions import ( |
19 | 20 | RoborockAccountDoesNotExist, |
@@ -607,6 +608,28 @@ async def execute_scene(self, user_data: UserData, scene_id: int) -> None: |
607 | 608 | if not execute_scene_response.get("success"): |
608 | 609 | raise RoborockException(execute_scene_response) |
609 | 610 |
|
| 611 | + async def get_schedules(self, user_data: UserData, device_id: str) -> list[HomeDataSchedule]: |
| 612 | + rriot = user_data.rriot |
| 613 | + if rriot is None: |
| 614 | + raise RoborockException("rriot is none") |
| 615 | + if rriot.r.a is None: |
| 616 | + raise RoborockException("Missing field 'a' in rriot reference") |
| 617 | + schedules_request = PreparedRequest( |
| 618 | + rriot.r.a, |
| 619 | + self.session, |
| 620 | + { |
| 621 | + "Authorization": _get_hawk_authentication(rriot, f"/user/devices/{device_id}/jobs"), |
| 622 | + }, |
| 623 | + ) |
| 624 | + schedules_response = await schedules_request.request("get", f"/user/devices/{str(device_id)}/jobs") |
| 625 | + if not schedules_response.get("success"): |
| 626 | + raise RoborockException(schedules_response) |
| 627 | + schedules = schedules_response.get("result") |
| 628 | + if isinstance(schedules, list): |
| 629 | + return [HomeDataSchedule.from_dict(schedule) for schedule in schedules] |
| 630 | + else: |
| 631 | + raise RoborockException(f"schedule_response result was an unexpected type: {schedules}") |
| 632 | + |
610 | 633 | async def get_products(self, user_data: UserData) -> ProductResponse: |
611 | 634 | """Gets all products and their schemas, good for determining status codes and model numbers.""" |
612 | 635 | base_url = await self.base_url |
|
0 commit comments