switchbot-api 2.12.0__tar.gz → 2.13.1__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.4
2
2
  Name: switchbot_api
3
- Version: 2.12.0
3
+ Version: 2.13.1
4
4
  Summary: An asynchronous library to use Switchbot API
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
17
18
  Requires-Dist: aiohttp (>=3.0.0)
18
19
  Requires-Dist: pycryptodome (>=3.23.0,<4.0.0)
19
20
  Project-URL: Repository, https://github.com/SeraphicCorp/py-switchbot-api
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "switchbot_api"
3
- version = "2.12.0"
3
+ version = "2.13.1"
4
4
  description = "An asynchronous library to use Switchbot API"
5
5
  authors = ["Ravaka Razafimanantsoa <contact@ravaka.dev>"]
6
6
  license = "MIT"
@@ -33,6 +33,7 @@ from switchbot_api.commands import (
33
33
  FanCommands,
34
34
  HumidifierCommands,
35
35
  HumidifierV2Commands,
36
+ KataFriendsCommands,
36
37
  KeyPadCommands,
37
38
  LightCommands,
38
39
  LockCommands,
@@ -57,14 +58,24 @@ from switchbot_api.exceptions import (
57
58
  SwitchBotAuthenticationError,
58
59
  SwitchBotConnectionError,
59
60
  SwitchBotDeviceOfflineError,
61
+ SwitchBotDeviceRequestError,
62
+ SwitchBotError,
60
63
  )
61
64
  from switchbot_api.models import (
62
65
  AirPurifierFanGear,
63
66
  AirPurifierMode,
67
+ AirPurifierModeV2,
68
+ BatteryCirculatorFan2ProMode,
64
69
  BatteryCirculatorFanMode,
65
70
  BatteryLevel,
71
+ Humidifier2Mode,
72
+ KataFriendsHospitalizedStatus,
73
+ KataFriendsMode,
74
+ KataFriendsWorkStatus,
66
75
  PowerState,
67
76
  SmartRadiatorThermostatMode,
77
+ Switch,
78
+ SwitchbotCloudDeviceLockState,
68
79
  VacuumCleanMode,
69
80
  VacuumFanSpeed,
70
81
  VacuumFanSpeedV2,
@@ -75,7 +86,9 @@ __all__ = [
75
86
  "AirPurifierCommands",
76
87
  "AirPurifierFanGear",
77
88
  "AirPurifierMode",
89
+ "AirPurifierModeV2",
78
90
  "ArtFrameCommands",
91
+ "BatteryCirculatorFan2ProMode",
79
92
  "BatteryCirculatorFanCommands",
80
93
  "BatteryCirculatorFanMode",
81
94
  "BatteryLevel",
@@ -89,8 +102,13 @@ __all__ = [
89
102
  "Device",
90
103
  "DoorBellCommands",
91
104
  "FanCommands",
105
+ "Humidifier2Mode",
92
106
  "HumidifierCommands",
93
107
  "HumidifierV2Commands",
108
+ "KataFriendsCommands",
109
+ "KataFriendsHospitalizedStatus",
110
+ "KataFriendsMode",
111
+ "KataFriendsWorkStatus",
94
112
  "KeyPadCommands",
95
113
  "LightCommands",
96
114
  "LockCommands",
@@ -106,9 +124,16 @@ __all__ = [
106
124
  "SmartRadiatorThermostatCommands",
107
125
  "SmartRadiatorThermostatMode",
108
126
  "SpeakerCommands",
127
+ "Switch",
109
128
  "Switch2PMCommands",
110
129
  "SwitchBotAPI",
130
+ "SwitchBotAuthenticationError",
131
+ "SwitchBotConnectionError",
132
+ "SwitchBotDeviceOfflineError",
133
+ "SwitchBotDeviceRequestError",
134
+ "SwitchBotError",
111
135
  "SwitchCommands",
136
+ "SwitchbotCloudDeviceLockState",
112
137
  "T",
113
138
  "TVCommands",
114
139
  "VacuumCleanMode",
@@ -214,9 +239,11 @@ class SwitchBotAPI:
214
239
  except (
215
240
  ClientError,
216
241
  ClientResponseError,
217
- socket.gaierror,
218
242
  ) as exception:
219
- msg = "Error occurred while communicating with the SwitchBot API"
243
+ msg = f"Error occurred while communicating, Status Code: {exception}"
244
+ raise SwitchBotConnectionError(msg) from exception
245
+ except socket.gaierror as exception:
246
+ msg = "DNS resolution failed."
220
247
  raise SwitchBotConnectionError(msg) from exception
221
248
  if response.status == 403:
222
249
  raise SwitchBotAuthenticationError
@@ -241,6 +241,7 @@ class RGBWWLightCommands(Commands):
241
241
  "RGBICWW Floor Lamp",
242
242
  "RGBICWW Strip Light",
243
243
  "Permanent Outdoor Lights",
244
+ "RGBICWW Light Bars",
244
245
  ]
245
246
 
246
247
 
@@ -295,7 +296,7 @@ class ArtFrameCommands(Commands):
295
296
  @classmethod
296
297
  def get_supported_devices(cls) -> list[str]:
297
298
  """Get supported devices."""
298
- return ["AI Art Frame"]
299
+ return ["AI Art Frame", "AI Art Frame Luma"]
299
300
 
300
301
 
301
302
  class DoorBellCommands(Commands):
@@ -480,4 +481,20 @@ class KeyPadCommands(Commands):
480
481
  return ["Keypad", "Keypad Touch", "Keypad Vision", "Keypad Vision Pro"]
481
482
 
482
483
 
484
+ class KataFriendsCommands(Commands):
485
+ """Kata Friends commands."""
486
+
487
+ MODE = "mode"
488
+ BACK_HOME = "backHome"
489
+ SNAPSHOTS = "snapshots"
490
+ CHILD_LOCK = "childLock"
491
+ PICTURE_TAKING = "pictureTaking"
492
+ TALK = "talk"
493
+
494
+ @classmethod
495
+ def get_supported_devices(cls) -> list[str]:
496
+ """Get supported devices."""
497
+ return ["Kata Friends"]
498
+
499
+
483
500
  T = TypeVar("T", bound=CommonCommands)
@@ -21,6 +21,16 @@ class BatteryCirculatorFanMode(StrEnum):
21
21
  BABY = "baby"
22
22
 
23
23
 
24
+ class BatteryCirculatorFan2ProMode(StrEnum):
25
+ """Fan mode types [Battery Circulator Fan2 Pro] API."""
26
+
27
+ DIRECT = "direct"
28
+ NATURAL = "natural"
29
+ SLEEP = "sleep"
30
+ BABY = "baby"
31
+ HURRICANE = "hurricane"
32
+
33
+
24
34
  class AirPurifierMode(Enum):
25
35
  """mode types [Air Purifier] API."""
26
36
 
@@ -30,6 +40,20 @@ class AirPurifierMode(Enum):
30
40
  PET = 4
31
41
 
32
42
 
43
+ class AirPurifierModeV2(Enum):
44
+ """Air Purifier Modes."""
45
+
46
+ NORMAL = 1
47
+ AUTO = 2
48
+ SLEEP = 3
49
+ PET = 4
50
+
51
+ @classmethod
52
+ def get_modes(cls) -> list[str]:
53
+ """Return a list of available air purifier modes as lowercase strings."""
54
+ return [mode.name.lower() for mode in cls]
55
+
56
+
33
57
  class AirPurifierFanGear(Enum):
34
58
  """Air Purifier Fan Gear."""
35
59
 
@@ -108,3 +132,78 @@ class BatteryLevel(Enum):
108
132
  if 10 > value >= 0:
109
133
  return cls.Critical
110
134
  return cls.Unknown
135
+
136
+
137
+ class Switch(Enum):
138
+ """Switch parameter."""
139
+
140
+ ON = "on"
141
+ OFF = "off"
142
+
143
+
144
+ class KataFriendsMode(Enum):
145
+ """Kata Friends Mode."""
146
+
147
+ NORMAL = "Normal"
148
+ STANDBY = "Standby"
149
+ SLEEP = "Sleep"
150
+
151
+
152
+ class KataFriendsWorkStatus(Enum):
153
+ """Kata Friends Work Status."""
154
+
155
+ STROLLING = "Strolling"
156
+ WELCOMING_HOME = "Welcoming Home"
157
+ WAKE_UP_CALL = "Wake-up Call"
158
+ SLEEPING = "Sleeping"
159
+ PLAYING = "Playing"
160
+ RETURNING = "Returning"
161
+
162
+
163
+ class KataFriendsHospitalizedStatus(Enum):
164
+ """Kata Friends Hospitalized Status."""
165
+
166
+ NORMAL = 0
167
+ REPAIR = 1
168
+ MAINTAIN = 2
169
+ CLEAN = 3
170
+
171
+
172
+ class Humidifier2Mode(Enum):
173
+ """Enumerates the available modes for a SwitchBot humidifier2."""
174
+
175
+ HIGH = 1
176
+ MEDIUM = 2
177
+ LOW = 3
178
+ QUIET = 4
179
+ TARGET_HUMIDITY = 5
180
+ SLEEP = 6
181
+ AUTO = 7
182
+ DRYING_FILTER = 8
183
+
184
+ @classmethod
185
+ def get_modes(cls) -> list[str]:
186
+ """Return a list of available humidifier2 modes as lowercase strings."""
187
+ return [mode.name.lower() for mode in cls]
188
+
189
+
190
+ class SwitchbotCloudDeviceLockState(Enum):
191
+ """Lock State."""
192
+
193
+ LOCKED = "locked"
194
+ UNLOCKED = "unlocked"
195
+ LOCKING = "locking"
196
+ UNLOCKING = "unlocking"
197
+ JAMMED = "jammed"
198
+ LATCH_BOLT_LOCKED = "latchBoltLocked"
199
+ HALF_LOCKED = "halfLocked"
200
+
201
+ @classmethod
202
+ def get_states(cls) -> list[SwitchbotCloudDeviceLockState]:
203
+ """Get lock states."""
204
+ return list(cls)
205
+
206
+ @classmethod
207
+ def get_values(cls) -> list[str]:
208
+ """Get lock value."""
209
+ return [mode.value for mode in cls]
File without changes
File without changes