pyvesync 3.0.0__py3-none-any.whl
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.
- pyvesync/__init__.py +5 -0
- pyvesync/base_devices/__init__.py +35 -0
- pyvesync/base_devices/bulb_base.py +330 -0
- pyvesync/base_devices/fan_base.py +392 -0
- pyvesync/base_devices/fryer_base.py +68 -0
- pyvesync/base_devices/humidifier_base.py +462 -0
- pyvesync/base_devices/outlet_base.py +327 -0
- pyvesync/base_devices/purifier_base.py +525 -0
- pyvesync/base_devices/switch_base.py +271 -0
- pyvesync/base_devices/thermostat_base.py +283 -0
- pyvesync/base_devices/vesyncbasedevice.py +572 -0
- pyvesync/const.py +825 -0
- pyvesync/device_container.py +373 -0
- pyvesync/device_map.py +1172 -0
- pyvesync/devices/__init__.py +1 -0
- pyvesync/devices/vesyncbulb.py +1126 -0
- pyvesync/devices/vesyncfan.py +233 -0
- pyvesync/devices/vesynchumidifier.py +808 -0
- pyvesync/devices/vesynckitchen.py +651 -0
- pyvesync/devices/vesyncoutlet.py +954 -0
- pyvesync/devices/vesyncpurifier.py +990 -0
- pyvesync/devices/vesyncswitch.py +415 -0
- pyvesync/devices/vesyncthermostat.py +171 -0
- pyvesync/models/__init__.py +11 -0
- pyvesync/models/base_models.py +129 -0
- pyvesync/models/bulb_models.py +197 -0
- pyvesync/models/bypass_models.py +289 -0
- pyvesync/models/fan_models.py +47 -0
- pyvesync/models/fryer_models.py +34 -0
- pyvesync/models/home_models.py +169 -0
- pyvesync/models/humidifier_models.py +202 -0
- pyvesync/models/outlet_models.py +220 -0
- pyvesync/models/purifier_models.py +261 -0
- pyvesync/models/switch_models.py +101 -0
- pyvesync/models/thermostat_models.py +134 -0
- pyvesync/models/vesync_models.py +439 -0
- pyvesync/utils/__init__.py +1 -0
- pyvesync/utils/colors.py +250 -0
- pyvesync/utils/device_mixins.py +362 -0
- pyvesync/utils/enum_utils.py +26 -0
- pyvesync/utils/errors.py +867 -0
- pyvesync/utils/helpers.py +700 -0
- pyvesync/utils/logs.py +525 -0
- pyvesync/vesync.py +638 -0
- pyvesync/vesynchome.py +152 -0
- pyvesync-3.0.0.dist-info/METADATA +567 -0
- pyvesync-3.0.0.dist-info/RECORD +50 -0
- pyvesync-3.0.0.dist-info/WHEEL +5 -0
- pyvesync-3.0.0.dist-info/licenses/LICENSE +21 -0
- pyvesync-3.0.0.dist-info/top_level.txt +1 -0
pyvesync/utils/errors.py
ADDED
|
@@ -0,0 +1,867 @@
|
|
|
1
|
+
"""Module holding VeSync API Error Codes and Response statuses.
|
|
2
|
+
|
|
3
|
+
Error codes are pulled from the VeSync app source code. If there are unknown errors
|
|
4
|
+
that are not found, please open an issue on GitHub.
|
|
5
|
+
|
|
6
|
+
Errors are integers divided by 1000 and then multiplied by 1000 to
|
|
7
|
+
get the base error code. It also tries to check if the absolute value matches
|
|
8
|
+
as well.
|
|
9
|
+
|
|
10
|
+
This is used by the `pyvesync.utils.helpers.Helpers.process_dev_response` method to
|
|
11
|
+
retrieve response code information and store in the `last_response` device instance.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
The "check_device" key of the error dictionary is used to determine if the logger
|
|
15
|
+
should emit a warning to the user for critical device errors, such as a short
|
|
16
|
+
or voltage error.
|
|
17
|
+
|
|
18
|
+
The ResponseInfo class is used to define information regarding the error code or
|
|
19
|
+
indicate the request was successful. The ErrorTypes class is used to categorize the
|
|
20
|
+
error types. This is a WIP and subject to change. Should not be used for anything
|
|
21
|
+
other than the ErrorCodes error configuration.
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
Example of the error dictionary structure:
|
|
25
|
+
```python
|
|
26
|
+
pyvesync.errors.ErrorCodes.get_error_info("-11201022")
|
|
27
|
+
ResponseInfo(
|
|
28
|
+
name="PASSWORD_ERROR",
|
|
29
|
+
error_type=ErrorTypes.AUTHENTICATION,
|
|
30
|
+
msg="Invalid password"
|
|
31
|
+
critical_error=False,
|
|
32
|
+
operational_error=False,
|
|
33
|
+
device_online=None
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
device.last_response
|
|
37
|
+
# Returns the ResponseInfo object.
|
|
38
|
+
```
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
from __future__ import annotations
|
|
42
|
+
|
|
43
|
+
from dataclasses import dataclass
|
|
44
|
+
from enum import StrEnum
|
|
45
|
+
from types import MappingProxyType
|
|
46
|
+
|
|
47
|
+
from mashumaro.mixins.orjson import DataClassORJSONMixin
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class ResponseInfo(DataClassORJSONMixin):
|
|
52
|
+
"""Class holding response information and error code definitions and lookup methods.
|
|
53
|
+
|
|
54
|
+
Attributes:
|
|
55
|
+
name (str): Name of the error
|
|
56
|
+
error_type (ErrorTypes): Type of the error see `ErrorTypes`
|
|
57
|
+
message (str): Message for the error
|
|
58
|
+
critical_error (bool): A major error, such as a short or voltage error
|
|
59
|
+
operational_error (bool): Device connected but API error
|
|
60
|
+
device_online (bool | None): Device online status
|
|
61
|
+
response_data (dict | None): Response data from API - populated by the
|
|
62
|
+
process_dev_response method in the Helpers class and bypass mixin
|
|
63
|
+
methods.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
name: str
|
|
67
|
+
error_type: str
|
|
68
|
+
message: str
|
|
69
|
+
critical_error: bool = False
|
|
70
|
+
operational_error: bool = False # Device connected but API error
|
|
71
|
+
device_online: bool | None = None # Defaults to connected
|
|
72
|
+
response_data: dict | None = None # Response data from API
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ErrorTypes(StrEnum):
|
|
76
|
+
"""Error types for API return codes.
|
|
77
|
+
|
|
78
|
+
Attributes:
|
|
79
|
+
SUCCESS: Successful request
|
|
80
|
+
AUTHENTICATION: Authentication error
|
|
81
|
+
RATE_LIMIT: Rate limiting error
|
|
82
|
+
SERVER_ERROR: Server and connection error
|
|
83
|
+
REQUEST_ERROR: Error in Request parameters or method
|
|
84
|
+
DEVICE_ERROR: Device operational error, device
|
|
85
|
+
connected but cannot perform requested action
|
|
86
|
+
CONFIG_ERROR: Configuration error in user profie
|
|
87
|
+
DEVICE_OFFLINE: Device is offline, not connected
|
|
88
|
+
UNKNOWN_ERROR: Unknown error
|
|
89
|
+
BAD_RESPONSE: Bad response from API
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
SUCCESS = 'success'
|
|
93
|
+
AUTHENTICATION = 'auth_error'
|
|
94
|
+
RATE_LIMIT = 'rate_limit_error'
|
|
95
|
+
SERVER_ERROR = 'server_error'
|
|
96
|
+
REQUEST_ERROR = 'request_error'
|
|
97
|
+
DEVICE_ERROR = 'device_error'
|
|
98
|
+
CONFIG_ERROR = 'config_error'
|
|
99
|
+
DEVICE_OFFLINE = 'device_offline'
|
|
100
|
+
UNKNOWN_ERROR = 'unknown_error'
|
|
101
|
+
TOKEN_ERROR = 'token_error'
|
|
102
|
+
BAD_RESPONSE = 'bad_response'
|
|
103
|
+
CROSS_REGION = 'cross_region'
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class ErrorCodes:
|
|
107
|
+
"""Class holding error code definitions and lookup methods.
|
|
108
|
+
|
|
109
|
+
Taken from VeSync app source code. Values are `ErrorInfo` dataclasses.
|
|
110
|
+
|
|
111
|
+
Attributes:
|
|
112
|
+
errors (MappingProxyType[str, ErrorInfo]): Dictionary of error codes and
|
|
113
|
+
their meanings.
|
|
114
|
+
|
|
115
|
+
Example:
|
|
116
|
+
Error codes are taken from VeSync app source code, if there are unknown errors
|
|
117
|
+
that are not found, please open an issue on GitHub. The "critical_error" key of
|
|
118
|
+
the error dictionary is used to determine if the logger should emit a warning.
|
|
119
|
+
Used for device issues that are critical, such as a short or voltage error.
|
|
120
|
+
|
|
121
|
+
Each error dictionary is structured as follows:
|
|
122
|
+
```
|
|
123
|
+
ErrorInfo(
|
|
124
|
+
name: str,
|
|
125
|
+
error_type: ErrorType,
|
|
126
|
+
message: str,
|
|
127
|
+
critical_error: bool,
|
|
128
|
+
operational_error: bool,
|
|
129
|
+
device_online: bool
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The `cls.critical_error(error_code)` method is used to determine if the error
|
|
134
|
+
is a critical device error that should emit a warning.
|
|
135
|
+
|
|
136
|
+
`cls.get_error_info(error_code)` method is used to return the error dictionary
|
|
137
|
+
for a given error code.
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
errors: MappingProxyType[str, ResponseInfo] = MappingProxyType(
|
|
141
|
+
{
|
|
142
|
+
'-11260022': ResponseInfo(
|
|
143
|
+
'CROSS_REGION_ERROR',
|
|
144
|
+
ErrorTypes.CROSS_REGION,
|
|
145
|
+
'Cross region error',
|
|
146
|
+
),
|
|
147
|
+
'11': ResponseInfo(
|
|
148
|
+
'DEVICE_OFFLINE',
|
|
149
|
+
ErrorTypes.DEVICE_OFFLINE,
|
|
150
|
+
'Device offline',
|
|
151
|
+
device_online=False,
|
|
152
|
+
),
|
|
153
|
+
'4041004': ResponseInfo(
|
|
154
|
+
'DEVICE_OFFLINE',
|
|
155
|
+
ErrorTypes.DEVICE_OFFLINE,
|
|
156
|
+
'Device offline',
|
|
157
|
+
device_online=False,
|
|
158
|
+
),
|
|
159
|
+
'-11203000': ResponseInfo(
|
|
160
|
+
'ACCOUNT_EXIST', ErrorTypes.AUTHENTICATION, 'Account already exists'
|
|
161
|
+
),
|
|
162
|
+
'-11200000': ResponseInfo(
|
|
163
|
+
'ACCOUNT_FORMAT_ERROR', ErrorTypes.CONFIG_ERROR, 'Account format error'
|
|
164
|
+
),
|
|
165
|
+
'-11202000': ResponseInfo(
|
|
166
|
+
'ACCOUNT_NOT_EXIST', ErrorTypes.AUTHENTICATION, 'Account does not exist'
|
|
167
|
+
),
|
|
168
|
+
'-11300027': ResponseInfo(
|
|
169
|
+
'AIRPURGE_OFFLINE',
|
|
170
|
+
ErrorTypes.DEVICE_OFFLINE,
|
|
171
|
+
'Device offline',
|
|
172
|
+
device_online=False,
|
|
173
|
+
),
|
|
174
|
+
'-16906000': ResponseInfo(
|
|
175
|
+
'REQUEST_TOO_FREQUENT',
|
|
176
|
+
ErrorTypes.RATE_LIMIT,
|
|
177
|
+
'Request too frequent',
|
|
178
|
+
operational_error=True,
|
|
179
|
+
),
|
|
180
|
+
'-11902000': ResponseInfo(
|
|
181
|
+
'AUTHKEY_NOT_EXIST', ErrorTypes.CONFIG_ERROR, 'Authkey does not exist'
|
|
182
|
+
),
|
|
183
|
+
'-11900000': ResponseInfo(
|
|
184
|
+
'AUTHKEY_PID_NOT_MATCH', ErrorTypes.DEVICE_ERROR, 'Authkey PID mismatch'
|
|
185
|
+
),
|
|
186
|
+
'-11504000': ResponseInfo(
|
|
187
|
+
'AWAY_MAX', ErrorTypes.CONFIG_ERROR, 'Away maximum reached'
|
|
188
|
+
),
|
|
189
|
+
'11014000': ResponseInfo(
|
|
190
|
+
'BYPASS_AIRPURIFIER_E2',
|
|
191
|
+
ErrorTypes.DEVICE_ERROR,
|
|
192
|
+
'Air Purifier E2 error',
|
|
193
|
+
critical_error=True,
|
|
194
|
+
device_online=True,
|
|
195
|
+
),
|
|
196
|
+
'11802000': ResponseInfo(
|
|
197
|
+
'BYPASS_AIRPURIFIER_MOTOR_ABNORMAL',
|
|
198
|
+
ErrorTypes.DEVICE_ERROR,
|
|
199
|
+
'Air Purifier motor error',
|
|
200
|
+
critical_error=True,
|
|
201
|
+
device_online=True,
|
|
202
|
+
),
|
|
203
|
+
'11504000': ResponseInfo(
|
|
204
|
+
'BYPASS_AWAY_MAX', ErrorTypes.CONFIG_ERROR, 'Away maximum reached'
|
|
205
|
+
),
|
|
206
|
+
'11509000': ResponseInfo(
|
|
207
|
+
'BYPASS_AWAY_NOT_EXIST',
|
|
208
|
+
ErrorTypes.CONFIG_ERROR,
|
|
209
|
+
'Away does not exist',
|
|
210
|
+
),
|
|
211
|
+
'11908000': ResponseInfo(
|
|
212
|
+
'BYPASS_COOK_TIMEOUT', ErrorTypes.DEVICE_ERROR, 'Cook timeout error'
|
|
213
|
+
),
|
|
214
|
+
'11909000': ResponseInfo(
|
|
215
|
+
'BYPASS_SMART_STOP',
|
|
216
|
+
ErrorTypes.DEVICE_ERROR,
|
|
217
|
+
'Smart stop error',
|
|
218
|
+
device_online=True,
|
|
219
|
+
),
|
|
220
|
+
'11910000': ResponseInfo(
|
|
221
|
+
'BYPASS_LEFT_ZONE_COOKING',
|
|
222
|
+
ErrorTypes.DEVICE_ERROR,
|
|
223
|
+
'Left zone cooking error',
|
|
224
|
+
device_online=True,
|
|
225
|
+
),
|
|
226
|
+
'11911000': ResponseInfo(
|
|
227
|
+
'BYPASS_RIGHT_ZONE_COOKING',
|
|
228
|
+
ErrorTypes.DEVICE_ERROR,
|
|
229
|
+
'Right zone cooking error',
|
|
230
|
+
device_online=True,
|
|
231
|
+
),
|
|
232
|
+
'11912000': ResponseInfo(
|
|
233
|
+
'BYPASS_ALL_ZONE_COOKING',
|
|
234
|
+
ErrorTypes.DEVICE_ERROR,
|
|
235
|
+
'All zone cooking error',
|
|
236
|
+
device_online=True,
|
|
237
|
+
),
|
|
238
|
+
'11916000': ResponseInfo(
|
|
239
|
+
'BYPASS_NTC_RIGHT_TOP_SHORT',
|
|
240
|
+
ErrorTypes.DEVICE_ERROR,
|
|
241
|
+
'Right top short error',
|
|
242
|
+
critical_error=True,
|
|
243
|
+
device_online=True,
|
|
244
|
+
),
|
|
245
|
+
'11917000': ResponseInfo(
|
|
246
|
+
'BYPASS_NTC_RIGHT_TOP_OPEN',
|
|
247
|
+
ErrorTypes.DEVICE_ERROR,
|
|
248
|
+
'Right top open error',
|
|
249
|
+
critical_error=True,
|
|
250
|
+
device_online=True,
|
|
251
|
+
),
|
|
252
|
+
'11918000': ResponseInfo(
|
|
253
|
+
'BYPASS_NTC_BOTTOM_SHORT',
|
|
254
|
+
ErrorTypes.DEVICE_ERROR,
|
|
255
|
+
'Bottom short error',
|
|
256
|
+
critical_error=True,
|
|
257
|
+
device_online=True,
|
|
258
|
+
),
|
|
259
|
+
'11919000': ResponseInfo(
|
|
260
|
+
'BYPASS_NTC_BOTTOM_OPEN',
|
|
261
|
+
ErrorTypes.DEVICE_ERROR,
|
|
262
|
+
'Bottom open error',
|
|
263
|
+
critical_error=True,
|
|
264
|
+
device_online=True,
|
|
265
|
+
),
|
|
266
|
+
'11924000': ResponseInfo(
|
|
267
|
+
'BYPASS_RIGHT_TEMP_FAULT',
|
|
268
|
+
ErrorTypes.DEVICE_ERROR,
|
|
269
|
+
'Right temperature fault',
|
|
270
|
+
critical_error=True,
|
|
271
|
+
device_online=True,
|
|
272
|
+
),
|
|
273
|
+
'11925000': ResponseInfo(
|
|
274
|
+
'BYPASS_ZONE_2_MOTOR_ABNORMAL',
|
|
275
|
+
ErrorTypes.DEVICE_ERROR,
|
|
276
|
+
'Zone 2 motor error',
|
|
277
|
+
critical_error=True,
|
|
278
|
+
device_online=True,
|
|
279
|
+
),
|
|
280
|
+
'11021000': ResponseInfo(
|
|
281
|
+
'BYPASS_DEVICE_END',
|
|
282
|
+
ErrorTypes.DEVICE_ERROR,
|
|
283
|
+
'Device end error',
|
|
284
|
+
critical_error=True,
|
|
285
|
+
device_online=True,
|
|
286
|
+
),
|
|
287
|
+
'11012000': ResponseInfo(
|
|
288
|
+
'BYPASS_DEVICE_RUNNING',
|
|
289
|
+
ErrorTypes.DEVICE_ERROR,
|
|
290
|
+
'Device running error',
|
|
291
|
+
critical_error=True,
|
|
292
|
+
device_online=True,
|
|
293
|
+
),
|
|
294
|
+
'11020000': ResponseInfo(
|
|
295
|
+
'BYPASS_DEVICE_STOP',
|
|
296
|
+
ErrorTypes.DEVICE_ERROR,
|
|
297
|
+
'Device stop error',
|
|
298
|
+
device_online=True,
|
|
299
|
+
critical_error=True,
|
|
300
|
+
),
|
|
301
|
+
'11901000': ResponseInfo(
|
|
302
|
+
'BYPASS_DOOR_OPEN',
|
|
303
|
+
ErrorTypes.DEVICE_ERROR,
|
|
304
|
+
'Door open error',
|
|
305
|
+
critical_error=True,
|
|
306
|
+
device_online=True,
|
|
307
|
+
),
|
|
308
|
+
'11006000': ResponseInfo(
|
|
309
|
+
'BYPASS_E1_OPEN',
|
|
310
|
+
ErrorTypes.DEVICE_ERROR,
|
|
311
|
+
'Open circuit error',
|
|
312
|
+
critical_error=True,
|
|
313
|
+
device_online=True,
|
|
314
|
+
),
|
|
315
|
+
'11007000': ResponseInfo(
|
|
316
|
+
'BYPASS_E2_SHORT',
|
|
317
|
+
ErrorTypes.DEVICE_ERROR,
|
|
318
|
+
'Short circuit error',
|
|
319
|
+
device_online=True,
|
|
320
|
+
critical_error=True,
|
|
321
|
+
),
|
|
322
|
+
'11015000': ResponseInfo(
|
|
323
|
+
'BYPASS_E3_WARM',
|
|
324
|
+
ErrorTypes.DEVICE_ERROR,
|
|
325
|
+
'Warm error',
|
|
326
|
+
critical_error=True,
|
|
327
|
+
device_online=True,
|
|
328
|
+
),
|
|
329
|
+
'11018000': ResponseInfo(
|
|
330
|
+
'BYPASS_SET_MIST_LEVEL',
|
|
331
|
+
ErrorTypes.DEVICE_ERROR,
|
|
332
|
+
'Cannot set mist level error',
|
|
333
|
+
device_online=True,
|
|
334
|
+
),
|
|
335
|
+
'11019000': ResponseInfo(
|
|
336
|
+
'BYPASS_E6_VOLTAGE_LOW',
|
|
337
|
+
ErrorTypes.DEVICE_ERROR,
|
|
338
|
+
'Low voltage error',
|
|
339
|
+
critical_error=True,
|
|
340
|
+
device_online=True,
|
|
341
|
+
),
|
|
342
|
+
'11013000': ResponseInfo(
|
|
343
|
+
'BYPASS_E7_VOLTAGE',
|
|
344
|
+
ErrorTypes.DEVICE_ERROR,
|
|
345
|
+
'Voltage error',
|
|
346
|
+
critical_error=True,
|
|
347
|
+
device_online=True,
|
|
348
|
+
),
|
|
349
|
+
'11607000': ResponseInfo(
|
|
350
|
+
'BYPASS_HUMIDIFIER_ERROR_CONNECT_MSG',
|
|
351
|
+
ErrorTypes.DEVICE_ERROR,
|
|
352
|
+
'Humidifier connect message error',
|
|
353
|
+
),
|
|
354
|
+
'11317000': ResponseInfo(
|
|
355
|
+
'BYPASS_DIMMER_NCT',
|
|
356
|
+
ErrorTypes.DEVICE_ERROR,
|
|
357
|
+
'Dimmer NCT error',
|
|
358
|
+
critical_error=True,
|
|
359
|
+
device_online=True,
|
|
360
|
+
),
|
|
361
|
+
'11608000': ResponseInfo(
|
|
362
|
+
'BYPASS_HUMIDIFIER_ERROR_WATER_PUMP',
|
|
363
|
+
ErrorTypes.DEVICE_ERROR,
|
|
364
|
+
'Humidifier water pump error',
|
|
365
|
+
critical_error=True,
|
|
366
|
+
device_online=True,
|
|
367
|
+
),
|
|
368
|
+
'11609000': ResponseInfo(
|
|
369
|
+
'BYPASS_HUMIDIFIER_ERROR_FAN_MOTOR',
|
|
370
|
+
ErrorTypes.DEVICE_ERROR,
|
|
371
|
+
'Humidifier fan motor error',
|
|
372
|
+
critical_error=True,
|
|
373
|
+
device_online=True,
|
|
374
|
+
),
|
|
375
|
+
'11601000': ResponseInfo(
|
|
376
|
+
'BYPASS_HUMIDIFIER_ERROR_DRY_BURNING',
|
|
377
|
+
ErrorTypes.DEVICE_ERROR,
|
|
378
|
+
'Dry burning error',
|
|
379
|
+
critical_error=True,
|
|
380
|
+
device_online=True,
|
|
381
|
+
),
|
|
382
|
+
'11602000': ResponseInfo(
|
|
383
|
+
'BYPASS_HUMIDIFIER_ERROR_PTC',
|
|
384
|
+
ErrorTypes.DEVICE_ERROR,
|
|
385
|
+
'Humidifier PTC error',
|
|
386
|
+
critical_error=True,
|
|
387
|
+
device_online=True,
|
|
388
|
+
),
|
|
389
|
+
'11603000': ResponseInfo(
|
|
390
|
+
'BYPASS_HUMIDIFIER_ERROR_WARM_HIGH',
|
|
391
|
+
ErrorTypes.DEVICE_ERROR,
|
|
392
|
+
'Humidifier warm high error',
|
|
393
|
+
critical_error=True,
|
|
394
|
+
device_online=True,
|
|
395
|
+
),
|
|
396
|
+
'11604000': ResponseInfo(
|
|
397
|
+
'BYPASS_HUMIDIFIER_ERROR_WATER',
|
|
398
|
+
ErrorTypes.DEVICE_ERROR,
|
|
399
|
+
'Humidifier water error',
|
|
400
|
+
critical_error=True,
|
|
401
|
+
device_online=True,
|
|
402
|
+
),
|
|
403
|
+
'11907000': ResponseInfo(
|
|
404
|
+
'BYPASS_LOW_WATER',
|
|
405
|
+
ErrorTypes.DEVICE_ERROR,
|
|
406
|
+
'Low water error',
|
|
407
|
+
device_online=True,
|
|
408
|
+
critical_error=True,
|
|
409
|
+
),
|
|
410
|
+
'11028000': ResponseInfo(
|
|
411
|
+
'BYPASS_MOTOR_OPEN',
|
|
412
|
+
ErrorTypes.DEVICE_ERROR,
|
|
413
|
+
'Motor open error',
|
|
414
|
+
device_online=True,
|
|
415
|
+
critical_error=True,
|
|
416
|
+
),
|
|
417
|
+
'11017000': ResponseInfo(
|
|
418
|
+
'BYPASS_NOT_SUPPORTED', ErrorTypes.REQUEST_ERROR, 'Not supported error'
|
|
419
|
+
),
|
|
420
|
+
'11905000': ResponseInfo(
|
|
421
|
+
'BYPASS_NO_POT',
|
|
422
|
+
ErrorTypes.DEVICE_ERROR,
|
|
423
|
+
'No pot error',
|
|
424
|
+
device_online=True,
|
|
425
|
+
critical_error=True,
|
|
426
|
+
),
|
|
427
|
+
'12001000': ResponseInfo(
|
|
428
|
+
'BYPASS_LACK_FOOD',
|
|
429
|
+
ErrorTypes.DEVICE_ERROR,
|
|
430
|
+
'Lack of food error',
|
|
431
|
+
device_online=True,
|
|
432
|
+
critical_error=True,
|
|
433
|
+
),
|
|
434
|
+
'12002000': ResponseInfo(
|
|
435
|
+
'BYPASS_JAM_FOOD',
|
|
436
|
+
ErrorTypes.DEVICE_ERROR,
|
|
437
|
+
'Jam food error',
|
|
438
|
+
device_online=True,
|
|
439
|
+
critical_error=True,
|
|
440
|
+
),
|
|
441
|
+
'12003000': ResponseInfo(
|
|
442
|
+
'BYPASS_BLOCK_FOOD',
|
|
443
|
+
ErrorTypes.DEVICE_ERROR,
|
|
444
|
+
'Block food error',
|
|
445
|
+
device_online=True,
|
|
446
|
+
critical_error=True,
|
|
447
|
+
),
|
|
448
|
+
'12004000': ResponseInfo(
|
|
449
|
+
'BYPASS_PUMP_FAIL',
|
|
450
|
+
ErrorTypes.DEVICE_ERROR,
|
|
451
|
+
'Pump failure error',
|
|
452
|
+
device_online=True,
|
|
453
|
+
critical_error=True,
|
|
454
|
+
),
|
|
455
|
+
'12005000': ResponseInfo(
|
|
456
|
+
'BYPASS_CALI_FAIL',
|
|
457
|
+
ErrorTypes.DEVICE_ERROR,
|
|
458
|
+
'Calibration failure error',
|
|
459
|
+
device_online=True,
|
|
460
|
+
critical_error=True,
|
|
461
|
+
),
|
|
462
|
+
'11611000': ResponseInfo(
|
|
463
|
+
'BYPASS_FILTER_TRAY_ERROR',
|
|
464
|
+
ErrorTypes.DEVICE_ERROR,
|
|
465
|
+
'Filter tray error',
|
|
466
|
+
critical_error=True,
|
|
467
|
+
device_online=True,
|
|
468
|
+
),
|
|
469
|
+
'11610000': ResponseInfo(
|
|
470
|
+
'BYPASS_VALUE_ERROR',
|
|
471
|
+
ErrorTypes.DEVICE_ERROR,
|
|
472
|
+
'Value error',
|
|
473
|
+
critical_error=True,
|
|
474
|
+
device_online=True,
|
|
475
|
+
),
|
|
476
|
+
'11022000': ResponseInfo(
|
|
477
|
+
'BYPASS_CANNOT_SET_LEVEL',
|
|
478
|
+
ErrorTypes.DEVICE_ERROR,
|
|
479
|
+
'Cannot set level error',
|
|
480
|
+
critical_error=False,
|
|
481
|
+
device_online=True,
|
|
482
|
+
),
|
|
483
|
+
'11023000': ResponseInfo(
|
|
484
|
+
'BYPASS_NTC_BOTTOM_OPEN',
|
|
485
|
+
ErrorTypes.DEVICE_ERROR,
|
|
486
|
+
'NTC bottom open error',
|
|
487
|
+
critical_error=True,
|
|
488
|
+
device_online=True,
|
|
489
|
+
),
|
|
490
|
+
'11024000': ResponseInfo(
|
|
491
|
+
'BYPASS_NTC_BOTTOM_SHORT',
|
|
492
|
+
ErrorTypes.DEVICE_ERROR,
|
|
493
|
+
'NTC bottom short error',
|
|
494
|
+
critical_error=True,
|
|
495
|
+
device_online=True,
|
|
496
|
+
),
|
|
497
|
+
'11026000': ResponseInfo(
|
|
498
|
+
'BYPASS_NTC_TOP_OPEN',
|
|
499
|
+
ErrorTypes.DEVICE_ERROR,
|
|
500
|
+
'NTC top open error',
|
|
501
|
+
critical_error=True,
|
|
502
|
+
device_online=True,
|
|
503
|
+
),
|
|
504
|
+
'11025000': ResponseInfo(
|
|
505
|
+
'BYPASS_NTC_TOP_SHORT',
|
|
506
|
+
ErrorTypes.DEVICE_ERROR,
|
|
507
|
+
'NTC top short error',
|
|
508
|
+
critical_error=True,
|
|
509
|
+
device_online=True,
|
|
510
|
+
),
|
|
511
|
+
'11027000': ResponseInfo(
|
|
512
|
+
'BYPASS_OPEN_HEAT_PIPE_OR_OPEN_FUSE',
|
|
513
|
+
ErrorTypes.DEVICE_ERROR,
|
|
514
|
+
'Open heat pipe or fuse error',
|
|
515
|
+
critical_error=True,
|
|
516
|
+
device_online=True,
|
|
517
|
+
),
|
|
518
|
+
'11906000': ResponseInfo(
|
|
519
|
+
'BYPASS_OVER_HEATED',
|
|
520
|
+
ErrorTypes.DEVICE_ERROR,
|
|
521
|
+
'Overheated error',
|
|
522
|
+
critical_error=True,
|
|
523
|
+
device_online=True,
|
|
524
|
+
),
|
|
525
|
+
'11000000': ResponseInfo(
|
|
526
|
+
'BYPASS_PARAMETER_INVALID',
|
|
527
|
+
ErrorTypes.REQUEST_ERROR,
|
|
528
|
+
'Invalid bypass parameter',
|
|
529
|
+
),
|
|
530
|
+
'11510000': ResponseInfo(
|
|
531
|
+
'BYPASS_SCHEDULE_CONFLICT', ErrorTypes.CONFIG_ERROR, 'Schedule conflict'
|
|
532
|
+
),
|
|
533
|
+
'11502000': ResponseInfo(
|
|
534
|
+
'BYPASS_SCHEDULE_MAX',
|
|
535
|
+
ErrorTypes.CONFIG_ERROR,
|
|
536
|
+
'Maximum number of schedules reached',
|
|
537
|
+
),
|
|
538
|
+
'11507000': ResponseInfo(
|
|
539
|
+
'BYPASS_SCHEDULE_NOT_EXIST',
|
|
540
|
+
ErrorTypes.CONFIG_ERROR,
|
|
541
|
+
'Schedule does not exist',
|
|
542
|
+
),
|
|
543
|
+
'11503000': ResponseInfo(
|
|
544
|
+
'TIMER_MAX',
|
|
545
|
+
ErrorTypes.CONFIG_ERROR,
|
|
546
|
+
'Maximum number of timers reached',
|
|
547
|
+
),
|
|
548
|
+
'11508000': ResponseInfo(
|
|
549
|
+
'TIMER_NOT_EXIST',
|
|
550
|
+
ErrorTypes.CONFIG_ERROR,
|
|
551
|
+
'Timer does not exist',
|
|
552
|
+
),
|
|
553
|
+
'11605000': ResponseInfo(
|
|
554
|
+
'BYPASS_WATER_LOCK',
|
|
555
|
+
ErrorTypes.DEVICE_ERROR,
|
|
556
|
+
'Water lock error',
|
|
557
|
+
critical_error=True,
|
|
558
|
+
device_online=True,
|
|
559
|
+
),
|
|
560
|
+
'11029000': ResponseInfo(
|
|
561
|
+
'BYPASS_WIFI_ERROR', ErrorTypes.DEVICE_ERROR, 'WiFi error'
|
|
562
|
+
),
|
|
563
|
+
'11902000': ResponseInfo(
|
|
564
|
+
'BY_PASS_ERROR_COOKING_158',
|
|
565
|
+
ErrorTypes.DEVICE_ERROR,
|
|
566
|
+
'Error setting cook mode, air fryer is already cooking',
|
|
567
|
+
device_online=True,
|
|
568
|
+
),
|
|
569
|
+
'11035000': ResponseInfo(
|
|
570
|
+
'BYPASS_MOTOR_ABNORMAL_ERROR',
|
|
571
|
+
ErrorTypes.DEVICE_ERROR,
|
|
572
|
+
'Motor abnormal error',
|
|
573
|
+
critical_error=True,
|
|
574
|
+
device_online=True,
|
|
575
|
+
),
|
|
576
|
+
'11903000': ResponseInfo(
|
|
577
|
+
'BY_PASS_ERROR_NOT_COOK_158',
|
|
578
|
+
ErrorTypes.DEVICE_ERROR,
|
|
579
|
+
'Error pausing, air fryer is not cooking',
|
|
580
|
+
device_online=True,
|
|
581
|
+
),
|
|
582
|
+
'-12001000': ResponseInfo(
|
|
583
|
+
'CONFIGKEY_EXPIRED', ErrorTypes.CONFIG_ERROR, 'Configkey expired'
|
|
584
|
+
),
|
|
585
|
+
'-12000000': ResponseInfo(
|
|
586
|
+
'CONFIGKEY_NOT_EXIST',
|
|
587
|
+
ErrorTypes.CONFIG_ERROR,
|
|
588
|
+
'Configkey does not exist',
|
|
589
|
+
),
|
|
590
|
+
'-11305000': ResponseInfo(
|
|
591
|
+
'CONFIG_MODULE_NOT_EXIST',
|
|
592
|
+
ErrorTypes.REQUEST_ERROR,
|
|
593
|
+
'Config module does not exist',
|
|
594
|
+
),
|
|
595
|
+
'-11100000': ResponseInfo(
|
|
596
|
+
'DATABASE_FAILED', ErrorTypes.SERVER_ERROR, 'Database error'
|
|
597
|
+
),
|
|
598
|
+
'-11101000': ResponseInfo(
|
|
599
|
+
'DATABASE_FAILED_ERROR', ErrorTypes.SERVER_ERROR, 'Database error'
|
|
600
|
+
),
|
|
601
|
+
'-11306000': ResponseInfo(
|
|
602
|
+
'DEVICE_BOUND',
|
|
603
|
+
ErrorTypes.CONFIG_ERROR,
|
|
604
|
+
'Device already associated with another account',
|
|
605
|
+
),
|
|
606
|
+
'-11301000': ResponseInfo(
|
|
607
|
+
'DEVICE_NOT_EXIST',
|
|
608
|
+
ErrorTypes.CONFIG_ERROR,
|
|
609
|
+
'Device does not exist',
|
|
610
|
+
device_online=False,
|
|
611
|
+
),
|
|
612
|
+
'-11300000': ResponseInfo(
|
|
613
|
+
'DEVICE_OFFLINE',
|
|
614
|
+
ErrorTypes.DEVICE_OFFLINE,
|
|
615
|
+
'Device offline',
|
|
616
|
+
device_online=False,
|
|
617
|
+
),
|
|
618
|
+
'-11302000': ResponseInfo(
|
|
619
|
+
'DEVICE_TIMEOUT',
|
|
620
|
+
ErrorTypes.DEVICE_ERROR,
|
|
621
|
+
'Device timeout',
|
|
622
|
+
device_online=False,
|
|
623
|
+
),
|
|
624
|
+
'-11304000': ResponseInfo(
|
|
625
|
+
'DEVICE_TIMEZONE_DIFF',
|
|
626
|
+
ErrorTypes.CONFIG_ERROR,
|
|
627
|
+
'Device timezone difference',
|
|
628
|
+
),
|
|
629
|
+
'-11303000': ResponseInfo(
|
|
630
|
+
'FIRMWARE_LATEST',
|
|
631
|
+
ErrorTypes.CONFIG_ERROR,
|
|
632
|
+
'No firmware update available',
|
|
633
|
+
),
|
|
634
|
+
'-11102000': ResponseInfo(
|
|
635
|
+
'INTERNAL_ERROR', ErrorTypes.SERVER_ERROR, 'Internal server error'
|
|
636
|
+
),
|
|
637
|
+
'-11004000': ResponseInfo(
|
|
638
|
+
'METHOD_NOT_FOUND', ErrorTypes.REQUEST_ERROR, 'Method not found'
|
|
639
|
+
),
|
|
640
|
+
'-11107000': ResponseInfo(
|
|
641
|
+
'MONGODB_ERROR', ErrorTypes.SERVER_ERROR, 'MongoDB error'
|
|
642
|
+
),
|
|
643
|
+
'-11105000': ResponseInfo(
|
|
644
|
+
'MYSQL_ERROR', ErrorTypes.SERVER_ERROR, 'MySQL error'
|
|
645
|
+
),
|
|
646
|
+
'88888888': ResponseInfo(
|
|
647
|
+
'NETWORK_DISABLE', ErrorTypes.SERVER_ERROR, 'Network disabled'
|
|
648
|
+
),
|
|
649
|
+
'77777777': ResponseInfo(
|
|
650
|
+
'NETWORK_TIMEOUT', ErrorTypes.SERVER_ERROR, 'Network timeout'
|
|
651
|
+
),
|
|
652
|
+
'4031005': ResponseInfo(
|
|
653
|
+
'NO_PERMISSION_7A', ErrorTypes.DEVICE_ERROR, 'No 7A Permissions'
|
|
654
|
+
),
|
|
655
|
+
'-11201000': ResponseInfo(
|
|
656
|
+
'PASSWORD_ERROR', ErrorTypes.AUTHENTICATION, 'Invalid password'
|
|
657
|
+
),
|
|
658
|
+
'-11901000': ResponseInfo(
|
|
659
|
+
'PID_NOT_EXIST', ErrorTypes.DEVICE_ERROR, 'PID does not exist'
|
|
660
|
+
),
|
|
661
|
+
'-11106000': ResponseInfo(
|
|
662
|
+
'REDIS_ERROR', ErrorTypes.SERVER_ERROR, 'Redis error'
|
|
663
|
+
),
|
|
664
|
+
'-11003000': ResponseInfo(
|
|
665
|
+
'REQUEST_HIGH', ErrorTypes.RATE_LIMIT, 'Rate limiting error'
|
|
666
|
+
),
|
|
667
|
+
'-11005000': ResponseInfo(
|
|
668
|
+
'RESOURCE_NOT_EXIST',
|
|
669
|
+
ErrorTypes.REQUEST_ERROR,
|
|
670
|
+
'No device with ID found',
|
|
671
|
+
device_online=False,
|
|
672
|
+
),
|
|
673
|
+
'-11108000': ResponseInfo('S3_ERROR', ErrorTypes.SERVER_ERROR, 'S3 error'),
|
|
674
|
+
'-11502000': ResponseInfo(
|
|
675
|
+
'SCHEDULE_MAX',
|
|
676
|
+
ErrorTypes.CONFIG_ERROR,
|
|
677
|
+
'Maximum number of schedules reached',
|
|
678
|
+
),
|
|
679
|
+
'-11103000': ResponseInfo(
|
|
680
|
+
'SERVER_BUSY', ErrorTypes.SERVER_ERROR, 'Server busy'
|
|
681
|
+
),
|
|
682
|
+
'-11104000': ResponseInfo(
|
|
683
|
+
'SERVER_TIMEOUT', ErrorTypes.SERVER_ERROR, 'Server timeout'
|
|
684
|
+
),
|
|
685
|
+
'-11501000': ResponseInfo(
|
|
686
|
+
'TIMER_CONFLICT', ErrorTypes.DEVICE_ERROR, 'Timer conflict'
|
|
687
|
+
),
|
|
688
|
+
'-11503000': ResponseInfo(
|
|
689
|
+
'TIMER_MAX', ErrorTypes.DEVICE_ERROR, 'Maximum number of timers reached'
|
|
690
|
+
),
|
|
691
|
+
'-11500000': ResponseInfo(
|
|
692
|
+
'TIMER_NOT_EXIST', ErrorTypes.DEVICE_ERROR, 'Timer does not exist'
|
|
693
|
+
),
|
|
694
|
+
'-11001000': ResponseInfo(
|
|
695
|
+
'TOKEN_EXPIRED', ErrorTypes.TOKEN_ERROR, 'Invalid token'
|
|
696
|
+
),
|
|
697
|
+
'-999999999': ResponseInfo(
|
|
698
|
+
'UNKNOWN', ErrorTypes.SERVER_ERROR, 'Unknown error'
|
|
699
|
+
),
|
|
700
|
+
'-11307000': ResponseInfo(
|
|
701
|
+
'UUID_NOT_EXIST',
|
|
702
|
+
ErrorTypes.DEVICE_ERROR,
|
|
703
|
+
'Device UUID not found',
|
|
704
|
+
device_online=False,
|
|
705
|
+
),
|
|
706
|
+
'12102000': ResponseInfo(
|
|
707
|
+
'TEM_SENOR_ERROR',
|
|
708
|
+
ErrorTypes.DEVICE_ERROR,
|
|
709
|
+
'Temperature sensor error',
|
|
710
|
+
critical_error=True,
|
|
711
|
+
device_online=True,
|
|
712
|
+
),
|
|
713
|
+
'12103000': ResponseInfo(
|
|
714
|
+
'HUM_SENOR_ERROR',
|
|
715
|
+
ErrorTypes.DEVICE_ERROR,
|
|
716
|
+
'Humidity sensor error',
|
|
717
|
+
critical_error=True,
|
|
718
|
+
device_online=True,
|
|
719
|
+
),
|
|
720
|
+
'12101000': ResponseInfo(
|
|
721
|
+
'SENSOR_ERROR',
|
|
722
|
+
ErrorTypes.DEVICE_ERROR,
|
|
723
|
+
'Sensor error',
|
|
724
|
+
critical_error=True,
|
|
725
|
+
device_online=True,
|
|
726
|
+
),
|
|
727
|
+
'11005000': ResponseInfo(
|
|
728
|
+
'BYPASS_DEVICE_IS_OFF',
|
|
729
|
+
ErrorTypes.DEVICE_ERROR,
|
|
730
|
+
'Device is offDevice is off',
|
|
731
|
+
critical_error=True,
|
|
732
|
+
device_online=True,
|
|
733
|
+
),
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
@classmethod
|
|
738
|
+
def get_error_info(cls, error_code: str | int | None) -> ResponseInfo:
|
|
739
|
+
"""Return error dictionary for the given error code.
|
|
740
|
+
|
|
741
|
+
Args:
|
|
742
|
+
error_code (str | int): Error code to lookup.
|
|
743
|
+
|
|
744
|
+
Returns:
|
|
745
|
+
dict: Error dictionary for the given error code.
|
|
746
|
+
|
|
747
|
+
Example:
|
|
748
|
+
```python
|
|
749
|
+
ErrorCodes.get_error_info("-11201022")
|
|
750
|
+
ErrorInfo(
|
|
751
|
+
"PASSWORD_ERROR", ErrorTypes.AUTHENTICATION, "Invalid password"
|
|
752
|
+
)
|
|
753
|
+
```
|
|
754
|
+
"""
|
|
755
|
+
try:
|
|
756
|
+
if error_code is None:
|
|
757
|
+
return ResponseInfo('UNKNOWN', ErrorTypes.UNKNOWN_ERROR, 'Unknown error')
|
|
758
|
+
error_str = str(error_code)
|
|
759
|
+
error_int = int(error_code)
|
|
760
|
+
if error_str == '0':
|
|
761
|
+
return ResponseInfo('SUCCESS', ErrorTypes.SUCCESS, 'Success')
|
|
762
|
+
if error_str in cls.errors:
|
|
763
|
+
return cls.errors[error_str]
|
|
764
|
+
error_code = int(error_int / 1000) * 1000
|
|
765
|
+
return cls.errors[str(error_code)]
|
|
766
|
+
except (ValueError, TypeError, KeyError):
|
|
767
|
+
return ResponseInfo('UNKNOWN', ErrorTypes.UNKNOWN_ERROR, 'Unknown error')
|
|
768
|
+
|
|
769
|
+
@classmethod
|
|
770
|
+
def is_critical(cls, error_code: str | int) -> bool:
|
|
771
|
+
"""Check if error code is a device error.
|
|
772
|
+
|
|
773
|
+
Args:
|
|
774
|
+
error_code (str | int): Error code to check.
|
|
775
|
+
|
|
776
|
+
Returns:
|
|
777
|
+
bool: True if error code is a device error, False otherwise.
|
|
778
|
+
"""
|
|
779
|
+
error_info = cls.get_error_info(error_code)
|
|
780
|
+
return bool(error_info.critical_error)
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
class VeSyncError(Exception):
|
|
784
|
+
"""Base exception for VeSync errors.
|
|
785
|
+
|
|
786
|
+
These are raised based on API response codes and exceptions
|
|
787
|
+
that may be raised by the different handlers.
|
|
788
|
+
"""
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
class VeSyncLoginError(VeSyncError):
|
|
792
|
+
"""Exception raised for login authentication errors."""
|
|
793
|
+
|
|
794
|
+
def __init__(self, msg: str) -> None:
|
|
795
|
+
"""Initialize the exception with a message."""
|
|
796
|
+
super().__init__(msg)
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
class VeSyncTokenError(VeSyncError):
|
|
800
|
+
"""Exception raised for VeSync API authentication errors."""
|
|
801
|
+
|
|
802
|
+
def __init__(self) -> None:
|
|
803
|
+
"""Initialize the exception with a message."""
|
|
804
|
+
super().__init__('Token expired or invalid - please re-authenticate with login()')
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
class VeSyncServerError(VeSyncError):
|
|
808
|
+
"""Exception raised for VeSync API server errors."""
|
|
809
|
+
|
|
810
|
+
def __init__(self, msg: str) -> None:
|
|
811
|
+
"""Initialize the exception with a message."""
|
|
812
|
+
super().__init__(msg)
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
class VeSyncRateLimitError(VeSyncError):
|
|
816
|
+
"""Exception raised for VeSync API rate limit errors."""
|
|
817
|
+
|
|
818
|
+
def __init__(self) -> None:
|
|
819
|
+
"""Initialize the exception with a message."""
|
|
820
|
+
super().__init__('VeSync API rate limit exceeded')
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
class VeSyncAPIResponseError(VeSyncError):
|
|
824
|
+
"""Exception raised for malformed VeSync API responses."""
|
|
825
|
+
|
|
826
|
+
def __init__(self, msg: None | str = None) -> None:
|
|
827
|
+
"""Initialize the exception with a message."""
|
|
828
|
+
if msg is None:
|
|
829
|
+
msg = 'Unexpected VeSync API response.'
|
|
830
|
+
super().__init__(msg)
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
class VeSyncAPIStatusCodeError(VeSyncError):
|
|
834
|
+
"""Exception raised for malformed VeSync API responses."""
|
|
835
|
+
|
|
836
|
+
def __init__(self, status_code: str | None = None) -> None:
|
|
837
|
+
"""Initialize the exception with a message."""
|
|
838
|
+
message = 'VeSync API returned an unknown status code'
|
|
839
|
+
if status_code is not None:
|
|
840
|
+
message = f'VeSync API returned status code {status_code}'
|
|
841
|
+
super().__init__(message)
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
def raise_api_errors(error_info: ResponseInfo) -> None:
|
|
845
|
+
"""Raise the appropriate exception for API error code.
|
|
846
|
+
|
|
847
|
+
Called by `VeSync.async_call_api` method.
|
|
848
|
+
|
|
849
|
+
Raises:
|
|
850
|
+
VeSyncRateLimitError: Rate limit error
|
|
851
|
+
VeSyncLoginError: Authentication error
|
|
852
|
+
VeSyncTokenError: Token error
|
|
853
|
+
VeSyncServerError: Server error
|
|
854
|
+
"""
|
|
855
|
+
match error_info.error_type:
|
|
856
|
+
case ErrorTypes.RATE_LIMIT:
|
|
857
|
+
raise VeSyncRateLimitError
|
|
858
|
+
case ErrorTypes.AUTHENTICATION:
|
|
859
|
+
raise VeSyncLoginError(error_info.message)
|
|
860
|
+
case ErrorTypes.TOKEN_ERROR:
|
|
861
|
+
raise VeSyncTokenError
|
|
862
|
+
case ErrorTypes.SERVER_ERROR:
|
|
863
|
+
msg = (
|
|
864
|
+
f'{error_info.message} - '
|
|
865
|
+
'Please report error to github.com/webdjoe/pyvesync/issues'
|
|
866
|
+
)
|
|
867
|
+
raise VeSyncServerError(msg)
|