switchbot-api 2.5.0__tar.gz → 2.7.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: switchbot_api
3
- Version: 2.5.0
3
+ Version: 2.7.0
4
4
  Summary: An asynchronous library to use Switchbot API
5
5
  License: MIT
6
6
  Author: Ravaka Razafimanantsoa
@@ -36,13 +36,30 @@ await client.send_command('some-id', {COMMAND})
36
36
  ### Install
37
37
 
38
38
  ```bash
39
- poetry install
39
+ make install
40
40
  ```
41
41
 
42
42
  ### Lint
43
43
 
44
44
  ```bash
45
- poetry run black switchbot_api/
46
- poetry run mypy switchbot_api/
45
+ make format
46
+ ```
47
+
48
+ ### Test
49
+
50
+ ```bash
51
+ make test
52
+ ```
53
+
54
+ ### build wheel
55
+
56
+ ```bash
57
+ make build
58
+ ```
59
+
60
+ ### Clean
61
+
62
+ ```bash
63
+ make clean
47
64
  ```
48
65
 
@@ -18,12 +18,29 @@ await client.send_command('some-id', {COMMAND})
18
18
  ### Install
19
19
 
20
20
  ```bash
21
- poetry install
21
+ make install
22
22
  ```
23
23
 
24
24
  ### Lint
25
25
 
26
26
  ```bash
27
- poetry run black switchbot_api/
28
- poetry run mypy switchbot_api/
27
+ make format
28
+ ```
29
+
30
+ ### Test
31
+
32
+ ```bash
33
+ make test
34
+ ```
35
+
36
+ ### build wheel
37
+
38
+ ```bash
39
+ make build
40
+ ```
41
+
42
+ ### Clean
43
+
44
+ ```bash
45
+ make clean
29
46
  ```
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "switchbot_api"
3
- version = "2.5.0"
3
+ version = "2.7.0"
4
4
  description = "An asynchronous library to use Switchbot API"
5
5
  authors = ["Ravaka Razafimanantsoa <contact@ravaka.dev>"]
6
6
  license = "MIT"
@@ -4,23 +4,97 @@ 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, TypeVar
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
+ SpeakerCommands,
41
+ Switch2PMCommands,
42
+ SwitchCommands,
43
+ T,
44
+ TVCommands,
45
+ VacuumCleanerV2Commands,
46
+ VacuumCleanerV3Commands,
47
+ VacuumCommands,
48
+ )
19
49
  from switchbot_api.exceptions import (
20
50
  SwitchBotAuthenticationError,
21
51
  SwitchBotConnectionError,
22
52
  SwitchBotDeviceOfflineError,
23
53
  )
54
+ from switchbot_api.models import (
55
+ BatteryCirculatorFanMode,
56
+ PowerState,
57
+ VacuumCleanMode,
58
+ VacuumFanSpeed,
59
+ VacuumFanSpeedV2,
60
+ )
61
+
62
+ __all__ = [
63
+ "AirConditionerCommands",
64
+ "AirPurifierCommands",
65
+ "BatteryCirculatorFanCommands",
66
+ "BatteryCirculatorFanMode",
67
+ "BlindTiltCommands",
68
+ "BotCommands",
69
+ "CeilingLightCommands",
70
+ "Commands",
71
+ "CommonCommands",
72
+ "CurtainCommands",
73
+ "DVDCommands",
74
+ "DoorBellCommands",
75
+ "FanCommands",
76
+ "HumidifierCommands",
77
+ "HumidifierV2Commands",
78
+ "LightCommands",
79
+ "LockCommands",
80
+ "LockV2Commands",
81
+ "OthersCommands",
82
+ "PowerState",
83
+ "RGBWLightCommands",
84
+ "RGBWWLightCommands",
85
+ "RollerShadeCommands",
86
+ "SpeakerCommands",
87
+ "Switch2PMCommands",
88
+ "SwitchCommands",
89
+ "T",
90
+ "TVCommands",
91
+ "VacuumCleanMode",
92
+ "VacuumCleanerV2Commands",
93
+ "VacuumCleanerV3Commands",
94
+ "VacuumCommands",
95
+ "VacuumFanSpeed",
96
+ "VacuumFanSpeedV2",
97
+ ]
24
98
 
25
99
  _API_HOST = "https://api.switch-bot.com"
26
100
 
@@ -36,6 +110,8 @@ class Device:
36
110
  device_name: str
37
111
  device_type: str
38
112
  hub_device_id: str
113
+ group: bool
114
+ master: bool | None
39
115
 
40
116
  def __init__(self, **kwargs: Any) -> None:
41
117
  """Initialize."""
@@ -43,6 +119,8 @@ class Device:
43
119
  self.device_name = kwargs["deviceName"]
44
120
  self.device_type = kwargs.get("deviceType", "-")
45
121
  self.hub_device_id = kwargs["hubDeviceId"]
122
+ self.group = kwargs.get("group", False)
123
+ self.master = kwargs.get("master")
46
124
 
47
125
 
48
126
  @dataclass
@@ -62,261 +140,6 @@ class Remote:
62
140
  self.hub_device_id = kwargs["hubDeviceId"]
63
141
 
64
142
 
65
- class PowerState(Enum):
66
- """Power state."""
67
-
68
- ON = "on"
69
- OFF = "off"
70
-
71
-
72
- class Commands(Enum):
73
- """Base command class."""
74
-
75
-
76
- class CommonCommands(Commands):
77
- """Common commands."""
78
-
79
- ON = "turnOn"
80
- OFF = "turnOff"
81
- TOGGLE = "toggle"
82
-
83
-
84
- class OthersCommands(Commands):
85
- """Others commands."""
86
-
87
- CUSTOMIZE = "customize" # Command {user-defined button name}
88
-
89
-
90
- class AirConditionerCommands(Commands):
91
- """Air conditioner commands."""
92
-
93
- SET_ALL = "setAll" # parameter: {temperature},{mode},{fan speed},{power state}
94
-
95
-
96
- class HumidifierCommands(Commands):
97
- """Humidifier commands."""
98
-
99
- # parameter: auto, set to Auto Mode
100
- # 101, set atomization efficiency to 34%
101
- # 102, set atomization efficiency to 67%
102
- # 103, set atomization efficiency to 100%
103
- SET_MODE = "setMode"
104
-
105
-
106
- class HumidifierV2Commands(Commands):
107
- """Humidifier 2 commands."""
108
-
109
- SET_MODE = "setMode"
110
- SET_CHILD_LOCK = "setChildLock"
111
-
112
-
113
- class AirPurifierCommands(Commands):
114
- """Purifier commands."""
115
-
116
- # Supported Device List:
117
- # Air Purifier VOC
118
- # Air Purifier Table VOC
119
- # Air Purifier PM2.5
120
- # Air Purifier Table PM2.5
121
-
122
- SET_MODE = "setMode"
123
- SET_CHILD_LOCK = "setChildLock"
124
-
125
-
126
- class CurtainCommands(Commands):
127
- """Curtain & Curtain3 commands."""
128
-
129
- SET_POSITION = "setPosition"
130
- PAUSE = "pause"
131
-
132
-
133
- class SwitchCommands(Commands):
134
- """Switch commands."""
135
-
136
- # Supported Device List:
137
- # Relay Switch 1
138
- # Relay Switch 1PM
139
- SET_MODE = "setMode"
140
-
141
-
142
- class Switch2PMCommands(Commands):
143
- """Switch commands."""
144
-
145
- # Supported Device List:
146
- # Relay Switch 2PM
147
- SET_MODE = "setMode"
148
- SET_POSITION = "setPosition"
149
-
150
-
151
- class RGBWLightCommands(Commands):
152
- """RGBWLight commands."""
153
-
154
- # Supported Device List:
155
- # Strip Light
156
- SET_BRIGHTNESS = "setBrightness"
157
- SET_COLOR = "setColor"
158
-
159
-
160
- class RGBWWLightCommands(Commands):
161
- """RGBWwLight commands."""
162
-
163
- # Supported Device List:
164
- # Floor Lamp
165
- # Strip Light 3
166
- # Color Bulb
167
- SET_BRIGHTNESS = "setBrightness"
168
- SET_COLOR = "setColor"
169
- SET_COLOR_TEMPERATURE = "setColorTemperature"
170
-
171
-
172
- class DoorBellCommands(Commands):
173
- """Door Bell commands."""
174
-
175
- ENABLE = "enableMotionDetection"
176
- DISABLE = "disableMotionDetection"
177
-
178
-
179
- class VacuumCleanerV2Commands(Commands):
180
- """VacuumCleanerV2 commands."""
181
-
182
- # Supported Device List:
183
- # K20+ Pro
184
- # Robot Vacuum Cleaner K10+ Pro Combo
185
- START_CLEAN = "startClean"
186
- PAUSE = "pause"
187
- DOCK = "dock"
188
- SET_VOLUME = "setVolume"
189
- CHANGE_PARAM = "changeParam"
190
-
191
-
192
- class VacuumCleanerV3Commands(Commands):
193
- """VacuumCleanerV3 commands."""
194
-
195
- # Supported Device List:
196
- # Floor Cleaning Robot S10
197
- # S20
198
- START_CLEAN = "startClean"
199
- PAUSE = "pause"
200
- DOCK = "dock"
201
- SET_VOLUME = "setVolume"
202
- CHANGE_PARAM = "changeParam"
203
- ADD_WATER_FOR_HUMI = "addWaterForHumi"
204
- SELF_CLEAN = "selfClean"
205
-
206
-
207
- class BlindTiltCommands(Commands):
208
- """Blind Tilt commands."""
209
-
210
- SET_POSITION = "setPosition"
211
- FULLY_OPEN = "fullyOpen"
212
- CLOSE_UP = "closeUp"
213
- CLOSE_DOWN = "closeDown"
214
-
215
-
216
- class RollerShadeCommands(Commands):
217
- """Roller Shade commands."""
218
-
219
- SET_POSITION = "setPosition"
220
-
221
-
222
- class TVCommands(Commands):
223
- """TV commands."""
224
-
225
- SET_CHANNEL = "SetChannel"
226
- VOLUME_ADD = "volumeAdd"
227
- VOLUME_SUB = "volumeSub"
228
- CHANNEL_ADD = "channelAdd"
229
- CHANNEL_SUB = "channelSub"
230
-
231
-
232
- class DVDCommands(Commands):
233
- """DVD commands."""
234
-
235
- SET_MUTE = "setMute"
236
- FAST_FORWARD = "FastForward"
237
- REWIND = "Rewind"
238
- NEXT = "Next"
239
- PREVIOUS = "Previous"
240
- PAUSE = "Pause"
241
- PLAY = "Play"
242
- STOP = "Stop"
243
-
244
-
245
- class SpeakerCommands(Commands):
246
- """Speaker commands."""
247
-
248
- VOLUME_ADD = "volumeAdd"
249
- VOLUME_SUB = "volumeSub"
250
-
251
-
252
- class FanCommands(Commands):
253
- """Fan commands."""
254
-
255
- SWING = "swing"
256
- TIMER = "timer"
257
- LOW_SPEED = "lowSpeed"
258
- MIDDLE_SPEED = "middleSpeed"
259
- HIGH_SPEED = "highSpeed"
260
-
261
-
262
- class BatteryCirculatorFanCommands(Commands):
263
- """Command types for [Battery Circulator Fan] API."""
264
-
265
- SET_WIND_SPEED = "setWindSpeed"
266
- SET_WIND_MODE = "setWindMode"
267
- SET_NIGHT_LIGHT_MODE = "setNightLightMode"
268
-
269
-
270
- class LightCommands(Commands):
271
- """Light commands."""
272
-
273
- BRIGHTNESS_UP = "brightnessUp"
274
- BRIGHTNESS_DOWN = "brightnessDown"
275
-
276
-
277
- class LockCommands(Commands):
278
- """Lock commands."""
279
-
280
- LOCK = "lock"
281
- UNLOCK = "unlock"
282
-
283
-
284
- class CeilingLightCommands(Commands):
285
- """Ceiling light commands."""
286
-
287
- # 1-100
288
- SET_BRIGHTNESS = "setBrightness"
289
- # 2700-6500
290
- SET_COLOR_TEMPERATURE = "setColorTemperature"
291
-
292
-
293
- class VacuumCommands(Commands):
294
- """Vacuum commands."""
295
-
296
- START = "start"
297
- STOP = "stop"
298
- DOCK = "dock"
299
- POW_LEVEL = "PowLevel"
300
-
301
-
302
- class BotCommands(Commands):
303
- """Bot commands."""
304
-
305
- PRESS = "press"
306
-
307
-
308
- class BatteryCirculatorFanMode(StrEnum):
309
- """Fan mode types [Battery Circulator Fan] API."""
310
-
311
- DIRECT = "direct"
312
- NATURAL = "natural"
313
- SLEEP = "sleep"
314
- BABY = "baby"
315
-
316
-
317
- T = TypeVar("T", bound=CommonCommands)
318
-
319
-
320
143
  class SwitchBotAPI:
321
144
  """SwitchBot API."""
322
145
 
@@ -0,0 +1,387 @@
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
+ T = TypeVar("T", bound=CommonCommands)
@@ -0,0 +1,47 @@
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"
File without changes