switchbot-api 2.6.0__tar.gz → 2.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {switchbot_api-2.6.0 → switchbot_api-2.8.0}/PKG-INFO +4 -2
- {switchbot_api-2.6.0 → switchbot_api-2.8.0}/pyproject.toml +1 -1
- {switchbot_api-2.6.0 → switchbot_api-2.8.0}/switchbot_api/__init__.py +83 -257
- switchbot_api-2.8.0/switchbot_api/commands.py +399 -0
- switchbot_api-2.8.0/switchbot_api/models.py +70 -0
- {switchbot_api-2.6.0 → switchbot_api-2.8.0}/LICENSE +0 -0
- {switchbot_api-2.6.0 → switchbot_api-2.8.0}/README.md +0 -0
- {switchbot_api-2.6.0 → switchbot_api-2.8.0}/switchbot_api/exceptions.py +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: switchbot_api
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.0
|
|
4
4
|
Summary: An asynchronous library to use Switchbot API
|
|
5
5
|
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Author: Ravaka Razafimanantsoa
|
|
7
8
|
Author-email: contact@ravaka.dev
|
|
8
9
|
Requires-Python: >=3.10,<4.0
|
|
@@ -12,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
17
|
Requires-Dist: aiohttp (>=3.0.0)
|
|
16
18
|
Project-URL: Repository, https://github.com/SeraphicCorp/py-switchbot-api
|
|
17
19
|
Description-Content-Type: text/markdown
|
|
@@ -4,23 +4,104 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import base64
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
-
from enum import Enum, StrEnum
|
|
8
7
|
import hashlib
|
|
9
8
|
import hmac
|
|
10
9
|
import logging
|
|
11
10
|
import socket
|
|
12
11
|
import time
|
|
13
|
-
from typing import Any, Self
|
|
12
|
+
from typing import Any, Self
|
|
14
13
|
import uuid
|
|
15
14
|
|
|
16
15
|
from aiohttp import ClientError, ClientResponseError, ClientSession
|
|
17
16
|
from aiohttp.hdrs import METH_GET, METH_POST
|
|
18
17
|
|
|
18
|
+
from switchbot_api.commands import (
|
|
19
|
+
AirConditionerCommands,
|
|
20
|
+
AirPurifierCommands,
|
|
21
|
+
BatteryCirculatorFanCommands,
|
|
22
|
+
BlindTiltCommands,
|
|
23
|
+
BotCommands,
|
|
24
|
+
CeilingLightCommands,
|
|
25
|
+
Commands,
|
|
26
|
+
CommonCommands,
|
|
27
|
+
CurtainCommands,
|
|
28
|
+
DoorBellCommands,
|
|
29
|
+
DVDCommands,
|
|
30
|
+
FanCommands,
|
|
31
|
+
HumidifierCommands,
|
|
32
|
+
HumidifierV2Commands,
|
|
33
|
+
LightCommands,
|
|
34
|
+
LockCommands,
|
|
35
|
+
LockV2Commands,
|
|
36
|
+
OthersCommands,
|
|
37
|
+
RGBWLightCommands,
|
|
38
|
+
RGBWWLightCommands,
|
|
39
|
+
RollerShadeCommands,
|
|
40
|
+
SmartRadiatorThermostatCommands,
|
|
41
|
+
SpeakerCommands,
|
|
42
|
+
Switch2PMCommands,
|
|
43
|
+
SwitchCommands,
|
|
44
|
+
T,
|
|
45
|
+
TVCommands,
|
|
46
|
+
VacuumCleanerV2Commands,
|
|
47
|
+
VacuumCleanerV3Commands,
|
|
48
|
+
VacuumCommands,
|
|
49
|
+
)
|
|
19
50
|
from switchbot_api.exceptions import (
|
|
20
51
|
SwitchBotAuthenticationError,
|
|
21
52
|
SwitchBotConnectionError,
|
|
22
53
|
SwitchBotDeviceOfflineError,
|
|
23
54
|
)
|
|
55
|
+
from switchbot_api.models import (
|
|
56
|
+
BatteryCirculatorFanMode,
|
|
57
|
+
PowerState,
|
|
58
|
+
SmartRadiatorThermostatMode,
|
|
59
|
+
VacuumCleanMode,
|
|
60
|
+
VacuumFanSpeed,
|
|
61
|
+
VacuumFanSpeedV2,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
__all__ = [
|
|
65
|
+
"AirConditionerCommands",
|
|
66
|
+
"AirPurifierCommands",
|
|
67
|
+
"BatteryCirculatorFanCommands",
|
|
68
|
+
"BatteryCirculatorFanMode",
|
|
69
|
+
"BlindTiltCommands",
|
|
70
|
+
"BotCommands",
|
|
71
|
+
"CeilingLightCommands",
|
|
72
|
+
"Commands",
|
|
73
|
+
"CommonCommands",
|
|
74
|
+
"CurtainCommands",
|
|
75
|
+
"DVDCommands",
|
|
76
|
+
"Device",
|
|
77
|
+
"DoorBellCommands",
|
|
78
|
+
"FanCommands",
|
|
79
|
+
"HumidifierCommands",
|
|
80
|
+
"HumidifierV2Commands",
|
|
81
|
+
"LightCommands",
|
|
82
|
+
"LockCommands",
|
|
83
|
+
"LockV2Commands",
|
|
84
|
+
"OthersCommands",
|
|
85
|
+
"PowerState",
|
|
86
|
+
"RGBWLightCommands",
|
|
87
|
+
"RGBWWLightCommands",
|
|
88
|
+
"Remote",
|
|
89
|
+
"RollerShadeCommands",
|
|
90
|
+
"SmartRadiatorThermostatCommands",
|
|
91
|
+
"SmartRadiatorThermostatMode",
|
|
92
|
+
"SpeakerCommands",
|
|
93
|
+
"Switch2PMCommands",
|
|
94
|
+
"SwitchBotAPI",
|
|
95
|
+
"SwitchCommands",
|
|
96
|
+
"T",
|
|
97
|
+
"TVCommands",
|
|
98
|
+
"VacuumCleanMode",
|
|
99
|
+
"VacuumCleanerV2Commands",
|
|
100
|
+
"VacuumCleanerV3Commands",
|
|
101
|
+
"VacuumCommands",
|
|
102
|
+
"VacuumFanSpeed",
|
|
103
|
+
"VacuumFanSpeedV2",
|
|
104
|
+
]
|
|
24
105
|
|
|
25
106
|
_API_HOST = "https://api.switch-bot.com"
|
|
26
107
|
|
|
@@ -66,261 +147,6 @@ class Remote:
|
|
|
66
147
|
self.hub_device_id = kwargs["hubDeviceId"]
|
|
67
148
|
|
|
68
149
|
|
|
69
|
-
class PowerState(Enum):
|
|
70
|
-
"""Power state."""
|
|
71
|
-
|
|
72
|
-
ON = "on"
|
|
73
|
-
OFF = "off"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
class Commands(Enum):
|
|
77
|
-
"""Base command class."""
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class CommonCommands(Commands):
|
|
81
|
-
"""Common commands."""
|
|
82
|
-
|
|
83
|
-
ON = "turnOn"
|
|
84
|
-
OFF = "turnOff"
|
|
85
|
-
TOGGLE = "toggle"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class OthersCommands(Commands):
|
|
89
|
-
"""Others commands."""
|
|
90
|
-
|
|
91
|
-
CUSTOMIZE = "customize" # Command {user-defined button name}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
class AirConditionerCommands(Commands):
|
|
95
|
-
"""Air conditioner commands."""
|
|
96
|
-
|
|
97
|
-
SET_ALL = "setAll" # parameter: {temperature},{mode},{fan speed},{power state}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
class HumidifierCommands(Commands):
|
|
101
|
-
"""Humidifier commands."""
|
|
102
|
-
|
|
103
|
-
# parameter: auto, set to Auto Mode
|
|
104
|
-
# 101, set atomization efficiency to 34%
|
|
105
|
-
# 102, set atomization efficiency to 67%
|
|
106
|
-
# 103, set atomization efficiency to 100%
|
|
107
|
-
SET_MODE = "setMode"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class HumidifierV2Commands(Commands):
|
|
111
|
-
"""Humidifier 2 commands."""
|
|
112
|
-
|
|
113
|
-
SET_MODE = "setMode"
|
|
114
|
-
SET_CHILD_LOCK = "setChildLock"
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
class AirPurifierCommands(Commands):
|
|
118
|
-
"""Purifier commands."""
|
|
119
|
-
|
|
120
|
-
# Supported Device List:
|
|
121
|
-
# Air Purifier VOC
|
|
122
|
-
# Air Purifier Table VOC
|
|
123
|
-
# Air Purifier PM2.5
|
|
124
|
-
# Air Purifier Table PM2.5
|
|
125
|
-
|
|
126
|
-
SET_MODE = "setMode"
|
|
127
|
-
SET_CHILD_LOCK = "setChildLock"
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
class CurtainCommands(Commands):
|
|
131
|
-
"""Curtain & Curtain3 commands."""
|
|
132
|
-
|
|
133
|
-
SET_POSITION = "setPosition"
|
|
134
|
-
PAUSE = "pause"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
class SwitchCommands(Commands):
|
|
138
|
-
"""Switch commands."""
|
|
139
|
-
|
|
140
|
-
# Supported Device List:
|
|
141
|
-
# Relay Switch 1
|
|
142
|
-
# Relay Switch 1PM
|
|
143
|
-
SET_MODE = "setMode"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
class Switch2PMCommands(Commands):
|
|
147
|
-
"""Switch commands."""
|
|
148
|
-
|
|
149
|
-
# Supported Device List:
|
|
150
|
-
# Relay Switch 2PM
|
|
151
|
-
SET_MODE = "setMode"
|
|
152
|
-
SET_POSITION = "setPosition"
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
class RGBWLightCommands(Commands):
|
|
156
|
-
"""RGBWLight commands."""
|
|
157
|
-
|
|
158
|
-
# Supported Device List:
|
|
159
|
-
# Strip Light
|
|
160
|
-
SET_BRIGHTNESS = "setBrightness"
|
|
161
|
-
SET_COLOR = "setColor"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
class RGBWWLightCommands(Commands):
|
|
165
|
-
"""RGBWwLight commands."""
|
|
166
|
-
|
|
167
|
-
# Supported Device List:
|
|
168
|
-
# Floor Lamp
|
|
169
|
-
# Strip Light 3
|
|
170
|
-
# Color Bulb
|
|
171
|
-
SET_BRIGHTNESS = "setBrightness"
|
|
172
|
-
SET_COLOR = "setColor"
|
|
173
|
-
SET_COLOR_TEMPERATURE = "setColorTemperature"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
class DoorBellCommands(Commands):
|
|
177
|
-
"""Door Bell commands."""
|
|
178
|
-
|
|
179
|
-
ENABLE = "enableMotionDetection"
|
|
180
|
-
DISABLE = "disableMotionDetection"
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
class VacuumCleanerV2Commands(Commands):
|
|
184
|
-
"""VacuumCleanerV2 commands."""
|
|
185
|
-
|
|
186
|
-
# Supported Device List:
|
|
187
|
-
# K20+ Pro
|
|
188
|
-
# Robot Vacuum Cleaner K10+ Pro Combo
|
|
189
|
-
START_CLEAN = "startClean"
|
|
190
|
-
PAUSE = "pause"
|
|
191
|
-
DOCK = "dock"
|
|
192
|
-
SET_VOLUME = "setVolume"
|
|
193
|
-
CHANGE_PARAM = "changeParam"
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
class VacuumCleanerV3Commands(Commands):
|
|
197
|
-
"""VacuumCleanerV3 commands."""
|
|
198
|
-
|
|
199
|
-
# Supported Device List:
|
|
200
|
-
# Floor Cleaning Robot S10
|
|
201
|
-
# S20
|
|
202
|
-
START_CLEAN = "startClean"
|
|
203
|
-
PAUSE = "pause"
|
|
204
|
-
DOCK = "dock"
|
|
205
|
-
SET_VOLUME = "setVolume"
|
|
206
|
-
CHANGE_PARAM = "changeParam"
|
|
207
|
-
ADD_WATER_FOR_HUMI = "addWaterForHumi"
|
|
208
|
-
SELF_CLEAN = "selfClean"
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
class BlindTiltCommands(Commands):
|
|
212
|
-
"""Blind Tilt commands."""
|
|
213
|
-
|
|
214
|
-
SET_POSITION = "setPosition"
|
|
215
|
-
FULLY_OPEN = "fullyOpen"
|
|
216
|
-
CLOSE_UP = "closeUp"
|
|
217
|
-
CLOSE_DOWN = "closeDown"
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
class RollerShadeCommands(Commands):
|
|
221
|
-
"""Roller Shade commands."""
|
|
222
|
-
|
|
223
|
-
SET_POSITION = "setPosition"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
class TVCommands(Commands):
|
|
227
|
-
"""TV commands."""
|
|
228
|
-
|
|
229
|
-
SET_CHANNEL = "SetChannel"
|
|
230
|
-
VOLUME_ADD = "volumeAdd"
|
|
231
|
-
VOLUME_SUB = "volumeSub"
|
|
232
|
-
CHANNEL_ADD = "channelAdd"
|
|
233
|
-
CHANNEL_SUB = "channelSub"
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
class DVDCommands(Commands):
|
|
237
|
-
"""DVD commands."""
|
|
238
|
-
|
|
239
|
-
SET_MUTE = "setMute"
|
|
240
|
-
FAST_FORWARD = "FastForward"
|
|
241
|
-
REWIND = "Rewind"
|
|
242
|
-
NEXT = "Next"
|
|
243
|
-
PREVIOUS = "Previous"
|
|
244
|
-
PAUSE = "Pause"
|
|
245
|
-
PLAY = "Play"
|
|
246
|
-
STOP = "Stop"
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
class SpeakerCommands(Commands):
|
|
250
|
-
"""Speaker commands."""
|
|
251
|
-
|
|
252
|
-
VOLUME_ADD = "volumeAdd"
|
|
253
|
-
VOLUME_SUB = "volumeSub"
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
class FanCommands(Commands):
|
|
257
|
-
"""Fan commands."""
|
|
258
|
-
|
|
259
|
-
SWING = "swing"
|
|
260
|
-
TIMER = "timer"
|
|
261
|
-
LOW_SPEED = "lowSpeed"
|
|
262
|
-
MIDDLE_SPEED = "middleSpeed"
|
|
263
|
-
HIGH_SPEED = "highSpeed"
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
class BatteryCirculatorFanCommands(Commands):
|
|
267
|
-
"""Command types for [Battery Circulator Fan] API."""
|
|
268
|
-
|
|
269
|
-
SET_WIND_SPEED = "setWindSpeed"
|
|
270
|
-
SET_WIND_MODE = "setWindMode"
|
|
271
|
-
SET_NIGHT_LIGHT_MODE = "setNightLightMode"
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
class LightCommands(Commands):
|
|
275
|
-
"""Light commands."""
|
|
276
|
-
|
|
277
|
-
BRIGHTNESS_UP = "brightnessUp"
|
|
278
|
-
BRIGHTNESS_DOWN = "brightnessDown"
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
class LockCommands(Commands):
|
|
282
|
-
"""Lock commands."""
|
|
283
|
-
|
|
284
|
-
LOCK = "lock"
|
|
285
|
-
UNLOCK = "unlock"
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
class CeilingLightCommands(Commands):
|
|
289
|
-
"""Ceiling light commands."""
|
|
290
|
-
|
|
291
|
-
# 1-100
|
|
292
|
-
SET_BRIGHTNESS = "setBrightness"
|
|
293
|
-
# 2700-6500
|
|
294
|
-
SET_COLOR_TEMPERATURE = "setColorTemperature"
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
class VacuumCommands(Commands):
|
|
298
|
-
"""Vacuum commands."""
|
|
299
|
-
|
|
300
|
-
START = "start"
|
|
301
|
-
STOP = "stop"
|
|
302
|
-
DOCK = "dock"
|
|
303
|
-
POW_LEVEL = "PowLevel"
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
class BotCommands(Commands):
|
|
307
|
-
"""Bot commands."""
|
|
308
|
-
|
|
309
|
-
PRESS = "press"
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
class BatteryCirculatorFanMode(StrEnum):
|
|
313
|
-
"""Fan mode types [Battery Circulator Fan] API."""
|
|
314
|
-
|
|
315
|
-
DIRECT = "direct"
|
|
316
|
-
NATURAL = "natural"
|
|
317
|
-
SLEEP = "sleep"
|
|
318
|
-
BABY = "baby"
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
T = TypeVar("T", bound=CommonCommands)
|
|
322
|
-
|
|
323
|
-
|
|
324
150
|
class SwitchBotAPI:
|
|
325
151
|
"""SwitchBot API."""
|
|
326
152
|
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
"""Base Commands for SwitchBot API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from enum import Enum
|
|
6
|
+
from typing import TypeVar
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Commands(Enum):
|
|
10
|
+
"""Base command class."""
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def is_supported(cls, device_type: str) -> bool:
|
|
14
|
+
"""Is this commands supported this device type."""
|
|
15
|
+
return device_type in cls.get_supported_devices()
|
|
16
|
+
|
|
17
|
+
@classmethod
|
|
18
|
+
def get_supported_devices(cls) -> list[str]:
|
|
19
|
+
"""Get supported devices."""
|
|
20
|
+
return []
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CommonCommands(Commands):
|
|
24
|
+
"""Common commands."""
|
|
25
|
+
|
|
26
|
+
ON = "turnOn"
|
|
27
|
+
OFF = "turnOff"
|
|
28
|
+
TOGGLE = "toggle"
|
|
29
|
+
PRESS = "press"
|
|
30
|
+
|
|
31
|
+
# Considering the wide range of CommonCommands, they are not inherited here.
|
|
32
|
+
@classmethod
|
|
33
|
+
def is_supported(cls, device_type: str) -> bool:
|
|
34
|
+
"""Is this commands supported this device type."""
|
|
35
|
+
error_msg = "CommonCommands not implement this method"
|
|
36
|
+
raise NotImplementedError(error_msg)
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def get_supported_devices(cls) -> list[str]:
|
|
40
|
+
"""Get supported devices."""
|
|
41
|
+
error_msg = "CommonCommands not implement this method"
|
|
42
|
+
raise NotImplementedError(error_msg)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class BotCommands(Commands):
|
|
46
|
+
"""Bot commands."""
|
|
47
|
+
|
|
48
|
+
PRESS = "press"
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def get_supported_devices(cls) -> list[str]:
|
|
52
|
+
"""Get supported devices."""
|
|
53
|
+
return ["Bot"]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class OthersCommands(Commands):
|
|
57
|
+
"""Others commands."""
|
|
58
|
+
|
|
59
|
+
CUSTOMIZE = "customize" # Command {user-defined button name}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class CurtainCommands(Commands):
|
|
63
|
+
"""Curtain & Curtain3 commands."""
|
|
64
|
+
|
|
65
|
+
SET_POSITION = "setPosition" # parameter(str): index0,mode0,position0 e.g. 0,ff,80
|
|
66
|
+
PAUSE = "pause"
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def get_supported_devices(cls) -> list[str]:
|
|
70
|
+
"""Get supported devices."""
|
|
71
|
+
return ["Curtain", "Curtain 3"]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class LockCommands(Commands):
|
|
75
|
+
"""Lock commands."""
|
|
76
|
+
|
|
77
|
+
LOCK = "lock"
|
|
78
|
+
UNLOCK = "unlock"
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def get_supported_devices(cls) -> list[str]:
|
|
82
|
+
"""Get supported devices."""
|
|
83
|
+
return ["Smart Lock", "Smart Lock Lite", "Smart Lock Pro", "Smart Lock Ultra"]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class LockV2Commands(Commands):
|
|
87
|
+
"""Lock commands."""
|
|
88
|
+
|
|
89
|
+
LOCK = "lock"
|
|
90
|
+
UNLOCK = "unlock"
|
|
91
|
+
DEADBOLT = "deadbolt"
|
|
92
|
+
|
|
93
|
+
@classmethod
|
|
94
|
+
def get_supported_devices(cls) -> list[str]:
|
|
95
|
+
"""Get supported devices."""
|
|
96
|
+
return ["Smart Lock", "Smart Lock Pro", "Smart Lock Ultra"]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class HumidifierCommands(Commands):
|
|
100
|
+
"""Humidifier commands."""
|
|
101
|
+
|
|
102
|
+
# parameter: auto, set to Auto Mode
|
|
103
|
+
# 101, set atomization efficiency to 34%
|
|
104
|
+
# 102, set atomization efficiency to 67%
|
|
105
|
+
# 103, set atomization efficiency to 100%
|
|
106
|
+
SET_MODE = "setMode"
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
def get_supported_devices(cls) -> list[str]:
|
|
110
|
+
"""Get supported devices."""
|
|
111
|
+
return ["Humidifier"]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class HumidifierV2Commands(Commands):
|
|
115
|
+
"""Humidifier 2 commands."""
|
|
116
|
+
|
|
117
|
+
SET_MODE = "setMode"
|
|
118
|
+
SET_CHILD_LOCK = "setChildLock"
|
|
119
|
+
|
|
120
|
+
@classmethod
|
|
121
|
+
def get_supported_devices(cls) -> list[str]:
|
|
122
|
+
"""Get supported devices."""
|
|
123
|
+
return ["Humidifier 2"]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class AirPurifierCommands(Commands):
|
|
127
|
+
"""Purifier commands."""
|
|
128
|
+
|
|
129
|
+
# Supported Device list:
|
|
130
|
+
# Air Purifier VOC
|
|
131
|
+
# Air Purifier Table VOC
|
|
132
|
+
# Air Purifier PM2.5
|
|
133
|
+
# Air Purifier Table PM2.5
|
|
134
|
+
|
|
135
|
+
SET_MODE = "setMode"
|
|
136
|
+
SET_CHILD_LOCK = "setChildLock"
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def get_supported_devices(cls) -> list[str]:
|
|
140
|
+
"""Get supported devices."""
|
|
141
|
+
return [
|
|
142
|
+
"Air Purifier VOC",
|
|
143
|
+
"Air Purifier Table VOC",
|
|
144
|
+
"Air Purifier PM2.5",
|
|
145
|
+
"Air Purifier Table PM2.5",
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class AirConditionerCommands(Commands):
|
|
150
|
+
"""Air conditioner commands."""
|
|
151
|
+
|
|
152
|
+
SET_ALL = "setAll"
|
|
153
|
+
|
|
154
|
+
@classmethod
|
|
155
|
+
def get_supported_devices(cls) -> list[str]:
|
|
156
|
+
"""Get supported devices."""
|
|
157
|
+
return ["Air Conditioner"]
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class SwitchCommands(Commands):
|
|
161
|
+
"""Switch commands."""
|
|
162
|
+
|
|
163
|
+
# Supported Device list:
|
|
164
|
+
# Relay Switch 1
|
|
165
|
+
# Relay Switch 1PM
|
|
166
|
+
SET_MODE = "setMode"
|
|
167
|
+
|
|
168
|
+
@classmethod
|
|
169
|
+
def get_supported_devices(cls) -> list[str]:
|
|
170
|
+
"""Get supported devices."""
|
|
171
|
+
return ["Relay Switch 1", "Relay Switch 1PM"]
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class Switch2PMCommands(Commands):
|
|
175
|
+
"""Switch commands."""
|
|
176
|
+
|
|
177
|
+
# Supported Device list:
|
|
178
|
+
# Relay Switch 2PM
|
|
179
|
+
SET_MODE = "setMode"
|
|
180
|
+
SET_POSITION = "setPosition"
|
|
181
|
+
|
|
182
|
+
@classmethod
|
|
183
|
+
def get_supported_devices(cls) -> list[str]:
|
|
184
|
+
"""Get supported devices."""
|
|
185
|
+
return ["Relay Switch 2PM"]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class RGBWLightCommands(Commands):
|
|
189
|
+
"""RGBWLight commands."""
|
|
190
|
+
|
|
191
|
+
# Supported Device list:
|
|
192
|
+
# Strip Light
|
|
193
|
+
SET_BRIGHTNESS = "setBrightness"
|
|
194
|
+
SET_COLOR = "setColor"
|
|
195
|
+
|
|
196
|
+
@classmethod
|
|
197
|
+
def get_supported_devices(cls) -> list[str]:
|
|
198
|
+
"""Get supported devices."""
|
|
199
|
+
return ["Strip Light"]
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class RGBWWLightCommands(Commands):
|
|
203
|
+
"""RGBWwLight commands."""
|
|
204
|
+
|
|
205
|
+
# Supported Device list:
|
|
206
|
+
# Floor Lamp
|
|
207
|
+
# Strip Light 3
|
|
208
|
+
# Color Bulb
|
|
209
|
+
SET_BRIGHTNESS = "setBrightness"
|
|
210
|
+
SET_COLOR = "setColor"
|
|
211
|
+
SET_COLOR_TEMPERATURE = "setColorTemperature"
|
|
212
|
+
|
|
213
|
+
@classmethod
|
|
214
|
+
def get_supported_devices(cls) -> list[str]:
|
|
215
|
+
"""Get supported devices."""
|
|
216
|
+
return ["Strip Light 3", "Floor Lamp", "Color Bulb"]
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class DoorBellCommands(Commands):
|
|
220
|
+
"""Door Bell commands."""
|
|
221
|
+
|
|
222
|
+
ENABLE = "enableMotionDetection"
|
|
223
|
+
DISABLE = "disableMotionDetection"
|
|
224
|
+
|
|
225
|
+
@classmethod
|
|
226
|
+
def get_supported_devices(cls) -> list[str]:
|
|
227
|
+
"""Get supported devices."""
|
|
228
|
+
return ["Video Doorbell"]
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class VacuumCommands(Commands):
|
|
232
|
+
"""Vacuum commands."""
|
|
233
|
+
|
|
234
|
+
START = "start"
|
|
235
|
+
STOP = "stop"
|
|
236
|
+
DOCK = "dock"
|
|
237
|
+
POW_LEVEL = "PowLevel"
|
|
238
|
+
|
|
239
|
+
@classmethod
|
|
240
|
+
def get_supported_devices(cls) -> list[str]:
|
|
241
|
+
"""Get supported devices."""
|
|
242
|
+
return [
|
|
243
|
+
"K10+",
|
|
244
|
+
"K10+ Pro",
|
|
245
|
+
"Robot Vacuum Cleaner S1",
|
|
246
|
+
"Robot Vacuum Cleaner S1 Plus",
|
|
247
|
+
]
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class VacuumCleanerV2Commands(Commands):
|
|
251
|
+
"""VacuumCleanerV2 commands."""
|
|
252
|
+
|
|
253
|
+
# Supported Device list:
|
|
254
|
+
# K20+ Pro
|
|
255
|
+
# Robot Vacuum Cleaner K10+ Pro Combo
|
|
256
|
+
START_CLEAN = "startClean"
|
|
257
|
+
PAUSE = "pause"
|
|
258
|
+
DOCK = "dock"
|
|
259
|
+
SET_VOLUME = "setVolume"
|
|
260
|
+
CHANGE_PARAM = "changeParam"
|
|
261
|
+
|
|
262
|
+
@classmethod
|
|
263
|
+
def get_supported_devices(cls) -> list[str]:
|
|
264
|
+
"""Get supported devices."""
|
|
265
|
+
return ["K20+ Pro", "Robot Vacuum Cleaner K10+ Pro Combo"]
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
class VacuumCleanerV3Commands(Commands):
|
|
269
|
+
"""VacuumCleanerV3 commands."""
|
|
270
|
+
|
|
271
|
+
# Supported Device list:
|
|
272
|
+
# Floor Cleaning Robot S10
|
|
273
|
+
# S20
|
|
274
|
+
START_CLEAN = "startClean"
|
|
275
|
+
PAUSE = "pause"
|
|
276
|
+
DOCK = "dock"
|
|
277
|
+
SET_VOLUME = "setVolume"
|
|
278
|
+
CHANGE_PARAM = "changeParam"
|
|
279
|
+
ADD_WATER_FOR_HUMI = "addWaterForHumi"
|
|
280
|
+
SELF_CLEAN = "selfClean"
|
|
281
|
+
|
|
282
|
+
@classmethod
|
|
283
|
+
def get_supported_devices(cls) -> list[str]:
|
|
284
|
+
"""Get supported devices."""
|
|
285
|
+
return ["Robot Vacuum Cleaner S10", "S20"]
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
class CeilingLightCommands(Commands):
|
|
289
|
+
"""Ceiling light commands."""
|
|
290
|
+
|
|
291
|
+
# 1-100
|
|
292
|
+
SET_BRIGHTNESS = "setBrightness"
|
|
293
|
+
# 2700-6500
|
|
294
|
+
SET_COLOR_TEMPERATURE = "setColorTemperature"
|
|
295
|
+
|
|
296
|
+
@classmethod
|
|
297
|
+
def get_supported_devices(cls) -> list[str]:
|
|
298
|
+
"""Get supported devices."""
|
|
299
|
+
return ["Ceiling Light", "Ceiling Light Pro"]
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class BlindTiltCommands(Commands):
|
|
303
|
+
"""Blind Tilt commands."""
|
|
304
|
+
|
|
305
|
+
SET_POSITION = "setPosition"
|
|
306
|
+
FULLY_OPEN = "fullyOpen"
|
|
307
|
+
CLOSE_UP = "closeUp"
|
|
308
|
+
CLOSE_DOWN = "closeDown"
|
|
309
|
+
|
|
310
|
+
@classmethod
|
|
311
|
+
def get_supported_devices(cls) -> list[str]:
|
|
312
|
+
"""Get supported devices."""
|
|
313
|
+
return ["Blind Tilt"]
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class RollerShadeCommands(Commands):
|
|
317
|
+
"""Roller Shade commands."""
|
|
318
|
+
|
|
319
|
+
SET_POSITION = "setPosition"
|
|
320
|
+
|
|
321
|
+
@classmethod
|
|
322
|
+
def get_supported_devices(cls) -> list[str]:
|
|
323
|
+
"""Get supported devices."""
|
|
324
|
+
return ["Roller Shade"]
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
class BatteryCirculatorFanCommands(Commands):
|
|
328
|
+
"""Command types for [Battery Circulator Fan] API."""
|
|
329
|
+
|
|
330
|
+
SET_WIND_SPEED = "setWindSpeed"
|
|
331
|
+
SET_WIND_MODE = "setWindMode"
|
|
332
|
+
SET_NIGHT_LIGHT_MODE = "setNightLightMode"
|
|
333
|
+
|
|
334
|
+
@classmethod
|
|
335
|
+
def get_supported_devices(cls) -> list[str]:
|
|
336
|
+
"""Get supported devices."""
|
|
337
|
+
return ["Circulator Fan", "Battery Circulator Fan"]
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
class TVCommands(Commands):
|
|
341
|
+
"""TV commands."""
|
|
342
|
+
|
|
343
|
+
SET_CHANNEL = "SetChannel"
|
|
344
|
+
VOLUME_ADD = "volumeAdd"
|
|
345
|
+
VOLUME_SUB = "volumeSub"
|
|
346
|
+
CHANNEL_ADD = "channelAdd"
|
|
347
|
+
CHANNEL_SUB = "channelSub"
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class DVDCommands(Commands):
|
|
351
|
+
"""DVD commands."""
|
|
352
|
+
|
|
353
|
+
SET_MUTE = "setMute"
|
|
354
|
+
FAST_FORWARD = "FastForward"
|
|
355
|
+
REWIND = "Rewind"
|
|
356
|
+
NEXT = "Next"
|
|
357
|
+
PREVIOUS = "Previous"
|
|
358
|
+
PAUSE = "Pause"
|
|
359
|
+
PLAY = "Play"
|
|
360
|
+
STOP = "Stop"
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class SpeakerCommands(Commands):
|
|
364
|
+
"""Speaker commands."""
|
|
365
|
+
|
|
366
|
+
VOLUME_ADD = "volumeAdd"
|
|
367
|
+
VOLUME_SUB = "volumeSub"
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
class FanCommands(Commands):
|
|
371
|
+
"""Fan commands."""
|
|
372
|
+
|
|
373
|
+
SWING = "swing"
|
|
374
|
+
TIMER = "timer"
|
|
375
|
+
LOW_SPEED = "lowSpeed"
|
|
376
|
+
MIDDLE_SPEED = "middleSpeed"
|
|
377
|
+
HIGH_SPEED = "highSpeed"
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
class LightCommands(Commands):
|
|
381
|
+
"""Light commands."""
|
|
382
|
+
|
|
383
|
+
BRIGHTNESS_UP = "brightnessUp"
|
|
384
|
+
BRIGHTNESS_DOWN = "brightnessDown"
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class SmartRadiatorThermostatCommands(Commands):
|
|
388
|
+
"""Smart Radiator Thermostat commands."""
|
|
389
|
+
|
|
390
|
+
SET_MODE = "setMode"
|
|
391
|
+
SET_MANUAL_MODE_TEMPERATURE = "setManualModeTemperature"
|
|
392
|
+
|
|
393
|
+
@classmethod
|
|
394
|
+
def get_supported_devices(cls) -> list[str]:
|
|
395
|
+
"""Get supported devices."""
|
|
396
|
+
return ["Smart Radiator Thermostat"]
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
T = TypeVar("T", bound=CommonCommands)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""constant for SwitchBot API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from enum import Enum, StrEnum
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PowerState(Enum):
|
|
9
|
+
"""Power state."""
|
|
10
|
+
|
|
11
|
+
ON = "on"
|
|
12
|
+
OFF = "off"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BatteryCirculatorFanMode(StrEnum):
|
|
16
|
+
"""Fan mode types [Battery Circulator Fan] API."""
|
|
17
|
+
|
|
18
|
+
DIRECT = "direct"
|
|
19
|
+
NATURAL = "natural"
|
|
20
|
+
SLEEP = "sleep"
|
|
21
|
+
BABY = "baby"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class VacuumFanSpeed(StrEnum):
|
|
25
|
+
"""Fan options for VacuumCommands supported devices."""
|
|
26
|
+
|
|
27
|
+
VACUUM_FAN_SPEED_QUIET = "0"
|
|
28
|
+
VACUUM_FAN_SPEED_STANDARD = "1"
|
|
29
|
+
VACUUM_FAN_SPEED_STRONG = "2"
|
|
30
|
+
VACUUM_FAN_SPEED_MAX = "3"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class VacuumFanSpeedV2(StrEnum):
|
|
34
|
+
"""Fan options for VacuumV2Commands & VacuumV3Commands supported devices."""
|
|
35
|
+
|
|
36
|
+
VACUUM_FAN_SPEED_QUIET = "1"
|
|
37
|
+
VACUUM_FAN_SPEED_STANDARD = "2"
|
|
38
|
+
VACUUM_FAN_SPEED_STRONG = "3"
|
|
39
|
+
VACUUM_FAN_SPEED_MAX = "4"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class VacuumCleanMode(StrEnum):
|
|
43
|
+
"""Clean mode for Vacuum."""
|
|
44
|
+
|
|
45
|
+
SWEEP = "sweep"
|
|
46
|
+
MOP = "mop"
|
|
47
|
+
SWEEP_MOP = "sweep_mop"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class SmartRadiatorThermostatMode(Enum):
|
|
51
|
+
"""mode for Smart Radiator Thermostat ."""
|
|
52
|
+
|
|
53
|
+
SCHEDULE = 0
|
|
54
|
+
MANUAL = 1
|
|
55
|
+
OFF = 2
|
|
56
|
+
ENERGY_SAVING = 3
|
|
57
|
+
COMFORT = 4
|
|
58
|
+
FAST_HEATING = 5
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def get_all_modes(cls) -> list[SmartRadiatorThermostatMode]:
|
|
62
|
+
"""Get all modes as a list."""
|
|
63
|
+
return [
|
|
64
|
+
cls.SCHEDULE,
|
|
65
|
+
cls.MANUAL,
|
|
66
|
+
cls.OFF,
|
|
67
|
+
cls.ENERGY_SAVING,
|
|
68
|
+
cls.COMFORT,
|
|
69
|
+
cls.FAST_HEATING,
|
|
70
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|