|
18 | 18 | PlugDeviceStatus, |
19 | 19 | PlugMiniJpDeviceStatus, |
20 | 20 | PlugMiniUsDeviceStatus, |
| 21 | + RobotVacuumCleanerDeviceStatus, |
21 | 22 | SmartFanDeviceStatus, |
22 | 23 | StripLightDeviceStatus, |
23 | 24 | ) |
@@ -85,6 +86,10 @@ def create_by_api_object( # noqa |
85 | 86 | return Remote(client, device) |
86 | 87 | if device_type == DeviceType.LOCK: |
87 | 88 | return Lock(client, device) |
| 89 | + if device_type == DeviceType.ROBOT_VACUUM_CLEANER_S1: |
| 90 | + return RobotVacuumCleanerS1(client, device) |
| 91 | + if device_type == DeviceType.ROBOT_VACUUM_CLEANER_S1_PLUS: |
| 92 | + return RobotVacuumCleanerS1Plus(client, device) |
88 | 93 |
|
89 | 94 | raise TypeError(f"invalid physical device object: {device}") |
90 | 95 |
|
@@ -887,3 +892,54 @@ def lock_state(self) -> str: |
887 | 892 |
|
888 | 893 | def door_state(self) -> str: |
889 | 894 | return self.status().door_state |
| 895 | + |
| 896 | + |
| 897 | +class RobotVacuumCleanerS1(SwitchBotPhysicalDevice): |
| 898 | + def __init__(self, client: SwitchBotClient, device: APIPhysicalDeviceObject): |
| 899 | + super().__init__(client, device) |
| 900 | + self._check_device_type(DeviceType.ROBOT_VACUUM_CLEANER_S1) |
| 901 | + |
| 902 | + @staticmethod |
| 903 | + def create_by_id(client: SwitchBotClient, device_id: str) -> RobotVacuumCleanerS1: |
| 904 | + device = SwitchBotPhysicalDevice.get_device_by_id(client, device_id) |
| 905 | + return RobotVacuumCleanerS1(client, device) |
| 906 | + |
| 907 | + def status(self) -> RobotVacuumCleanerDeviceStatus: |
| 908 | + status = super().status() |
| 909 | + return RobotVacuumCleanerDeviceStatus( |
| 910 | + device_id=status.device_id, |
| 911 | + device_type=status.device_type, |
| 912 | + device_name=status.device_name, |
| 913 | + hub_device_id=status.hub_device_id, |
| 914 | + raw_data=status.raw_data, |
| 915 | + working_status=status.raw_data["working_status"], |
| 916 | + online_status=status.raw_data["online_status"], |
| 917 | + battery=status.raw_data["battery"], |
| 918 | + ) |
| 919 | + |
| 920 | + def working_status(self) -> str: |
| 921 | + return self.status().working_status |
| 922 | + |
| 923 | + def online_status(self) -> str: |
| 924 | + return self.status().online_status |
| 925 | + |
| 926 | + def battery(self) -> int: |
| 927 | + return self.status().battery |
| 928 | + |
| 929 | + def start(self) -> SwitchBotCommandResult: |
| 930 | + return self.command(ControlCommand.RobotVacuumCleaner.START) |
| 931 | + |
| 932 | + def stop(self) -> SwitchBotCommandResult: |
| 933 | + return self.command(ControlCommand.RobotVacuumCleaner.STOP) |
| 934 | + |
| 935 | + def dock(self) -> SwitchBotCommandResult: |
| 936 | + return self.command(ControlCommand.RobotVacuumCleaner.DOCK) |
| 937 | + |
| 938 | + def pow_level(self, level: int) -> SwitchBotCommandResult: |
| 939 | + return self.command(ControlCommand.RobotVacuumCleaner.POW_LEVEL, parameter=f"{level}") |
| 940 | + |
| 941 | + |
| 942 | +class RobotVacuumCleanerS1Plus(RobotVacuumCleanerS1): |
| 943 | + def __init__(self, client: SwitchBotClient, device: APIPhysicalDeviceObject): |
| 944 | + super().__init__(client, device) |
| 945 | + self._check_device_type(DeviceType.ROBOT_VACUUM_CLEANER_S1_PLUS) |
0 commit comments