Skip to content

Errors and Exceptions

The pyvesync library parses the code provided in the API response to determine if the request was successful and a possible reason for failure.

Module holding VeSync API Error Codes and Response statuses.

Error codes are pulled from the VeSync app source code. If there are unknown errors that are not found, please open an issue on GitHub.

Errors are integers divided by 1000 and then multiplied by 1000 to get the base error code. It also tries to check if the absolute value matches as well.

This is used by the pyvesync.utils.helpers.Helpers.process_dev_response method to retrieve response code information and store in the last_response device instance.

The "check_device" key of the error dictionary is used to determine if the logger should emit a warning to the user for critical device errors, such as a short or voltage error.

The ResponseInfo class is used to define information regarding the error code or indicate the request was successful. The ErrorTypes class is used to categorize the error types. This is a WIP and subject to change. Should not be used for anything other than the ErrorCodes error configuration.

Example

Example of the error dictionary structure:

pyvesync.errors.ErrorCodes.get_error_info("-11201022") ResponseInfo(  name="PASSWORD_ERROR",  error_type=ErrorTypes.AUTHENTICATION,  msg="Invalid password"  critical_error=False,  operational_error=False,  device_online=None )  device.last_response # Returns the ResponseInfo object. 

pyvesync.utils.errors.ResponseInfo dataclass

Bases: DataClassORJSONMixin

Class holding response information and error code definitions and lookup methods.

Attributes:

Name Type Description
name str

Name of the error

error_type ErrorTypes

Type of the error see ErrorTypes

message str

Message for the error

critical_error bool

A major error, such as a short or voltage error

operational_error bool

Device connected but API error

device_online bool | None

Device online status

code str | int | None

Error code from API

response_data dict | None

Response data from API - populated by the process_dev_response method in the Helpers class and bypass mixin methods.

Source code in src/pyvesync/utils/errors.py
@dataclass class ResponseInfo(DataClassORJSONMixin):  """Class holding response information and error code definitions and lookup methods.   Attributes:  name (str): Name of the error  error_type (ErrorTypes): Type of the error see `ErrorTypes`  message (str): Message for the error  critical_error (bool): A major error, such as a short or voltage error  operational_error (bool): Device connected but API error  device_online (bool | None): Device online status  code (str | int | None): Error code from API  response_data (dict | None): Response data from API - populated by the  process_dev_response method in the Helpers class and bypass mixin  methods.  """   name: str  error_type: str  message: str  critical_error: bool = False  operational_error: bool = False # Device connected but API error  device_online: bool = True # Defaults to connected  code: int | None = None  response_data: dict | None = None # Response data from API 

pyvesync.utils.errors.ErrorTypes

Bases: StrEnum

Error types for API return codes.

Attributes:

Name Type Description
SUCCESS

Successful request

AUTHENTICATION

Authentication error

RATE_LIMIT

Rate limiting error

SERVER_ERROR

Server and connection error

REQUEST_ERROR

Error in Request parameters or method

DEVICE_ERROR

Device operational error, device connected but cannot perform requested action

CONFIG_ERROR

Configuration error in user profile

DEVICE_OFFLINE

Device is offline, not connected

UNKNOWN_ERROR

Unknown error

BAD_RESPONSE

Bad response from API

Source code in src/pyvesync/utils/errors.py
class ErrorTypes(StrEnum):  """Error types for API return codes.   Attributes:  SUCCESS: Successful request  AUTHENTICATION: Authentication error  RATE_LIMIT: Rate limiting error  SERVER_ERROR: Server and connection error  REQUEST_ERROR: Error in Request parameters or method  DEVICE_ERROR: Device operational error, device  connected but cannot perform requested action  CONFIG_ERROR: Configuration error in user profile  DEVICE_OFFLINE: Device is offline, not connected  UNKNOWN_ERROR: Unknown error  BAD_RESPONSE: Bad response from API  """   SUCCESS = 'success'  AUTHENTICATION = 'auth_error'  RATE_LIMIT = 'rate_limit_error'  SERVER_ERROR = 'server_error'  REQUEST_ERROR = 'request_error'  DEVICE_ERROR = 'device_error'  CONFIG_ERROR = 'config_error'  DEVICE_OFFLINE = 'device_offline'  UNKNOWN_ERROR = 'unknown_error'  TOKEN_ERROR = 'token_error'  BAD_RESPONSE = 'bad_response'  CROSS_REGION = 'cross_region' 

pyvesync.utils.errors.ErrorCodes

Class holding error code definitions and lookup methods.

Taken from VeSync app source code. Values are ErrorInfo dataclasses.

Attributes:

Name Type Description
errors MappingProxyType[str, ErrorInfo]

Dictionary of error codes and their meanings.

Example

Error codes are taken from VeSync app source code, if there are unknown errors that are not found, please open an issue on GitHub. The "critical_error" key of the error dictionary is used to determine if the logger should emit a warning. Used for device issues that are critical, such as a short or voltage error.

Each error dictionary is structured as follows:

ErrorInfo(  name: str,  error_type: ErrorType,  message: str,  critical_error: bool,  operational_error: bool,  device_online: bool  ) 

The cls.critical_error(error_code) method is used to determine if the error is a critical device error that should emit a warning.

cls.get_error_info(error_code) method is used to return the error dictionary for a given error code.

Source code in src/pyvesync/utils/errors.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796
class ErrorCodes:  """Class holding error code definitions and lookup methods.   Taken from VeSync app source code. Values are `ErrorInfo` dataclasses.   Attributes:  errors (MappingProxyType[str, ErrorInfo]): Dictionary of error codes and  their meanings.   Example:  Error codes are taken from VeSync app source code, if there are unknown errors  that are not found, please open an issue on GitHub. The "critical_error" key of  the error dictionary is used to determine if the logger should emit a warning.  Used for device issues that are critical, such as a short or voltage error.   Each error dictionary is structured as follows:  ```  ErrorInfo(  name: str,  error_type: ErrorType,  message: str,  critical_error: bool,  operational_error: bool,  device_online: bool  )  ```   The `cls.critical_error(error_code)` method is used to determine if the error  is a critical device error that should emit a warning.   `cls.get_error_info(error_code)` method is used to return the error dictionary  for a given error code.  """   errors: MappingProxyType[str, ResponseInfo] = MappingProxyType(  {  '-11260022': ResponseInfo(  'CROSS_REGION_ERROR',  ErrorTypes.CROSS_REGION,  'Cross region error',  ),  '11': ResponseInfo(  'DEVICE_OFFLINE',  ErrorTypes.DEVICE_OFFLINE,  'Device offline',  device_online=False,  ),  '4041004': ResponseInfo(  'DEVICE_OFFLINE',  ErrorTypes.DEVICE_OFFLINE,  'Device offline',  device_online=False,  ),  '-11203000': ResponseInfo(  'ACCOUNT_EXIST', ErrorTypes.AUTHENTICATION, 'Account already exists'  ),  '-11200000': ResponseInfo(  'ACCOUNT_FORMAT_ERROR', ErrorTypes.CONFIG_ERROR, 'Account format error'  ),  '-11202000': ResponseInfo(  'ACCOUNT_NOT_EXIST', ErrorTypes.AUTHENTICATION, 'Account does not exist'  ),  '-11300027': ResponseInfo(  'AIRPURGE_OFFLINE',  ErrorTypes.DEVICE_OFFLINE,  'Device offline',  device_online=False,  ),  '-16906000': ResponseInfo(  'REQUEST_TOO_FREQUENT',  ErrorTypes.RATE_LIMIT,  'Request too frequent',  operational_error=True,  ),  '-11902000': ResponseInfo(  'AUTHKEY_NOT_EXIST', ErrorTypes.CONFIG_ERROR, 'Authkey does not exist'  ),  '-11900000': ResponseInfo(  'AUTHKEY_PID_NOT_MATCH', ErrorTypes.DEVICE_ERROR, 'Authkey PID mismatch'  ),  '-11504000': ResponseInfo(  'AWAY_MAX', ErrorTypes.CONFIG_ERROR, 'Away maximum reached'  ),  '11014000': ResponseInfo(  'BYPASS_AIRPURIFIER_E2',  ErrorTypes.DEVICE_ERROR,  'Air Purifier E2 error',  critical_error=True,  device_online=True,  ),  '11802000': ResponseInfo(  'BYPASS_AIRPURIFIER_MOTOR_ABNORMAL',  ErrorTypes.DEVICE_ERROR,  'Air Purifier motor error',  critical_error=True,  device_online=True,  ),  '11504000': ResponseInfo(  'BYPASS_AWAY_MAX', ErrorTypes.CONFIG_ERROR, 'Away maximum reached'  ),  '11509000': ResponseInfo(  'BYPASS_AWAY_NOT_EXIST',  ErrorTypes.CONFIG_ERROR,  'Away does not exist',  ),  '11908000': ResponseInfo(  'BYPASS_COOK_TIMEOUT', ErrorTypes.DEVICE_ERROR, 'Cook timeout error'  ),  '11909000': ResponseInfo(  'BYPASS_SMART_STOP',  ErrorTypes.DEVICE_ERROR,  'Smart stop error',  device_online=True,  ),  '11910000': ResponseInfo(  'BYPASS_LEFT_ZONE_COOKING',  ErrorTypes.DEVICE_ERROR,  'Left zone cooking error',  device_online=True,  ),  '11911000': ResponseInfo(  'BYPASS_RIGHT_ZONE_COOKING',  ErrorTypes.DEVICE_ERROR,  'Right zone cooking error',  device_online=True,  ),  '11912000': ResponseInfo(  'BYPASS_ALL_ZONE_COOKING',  ErrorTypes.DEVICE_ERROR,  'All zone cooking error',  device_online=True,  ),  '11916000': ResponseInfo(  'BYPASS_NTC_RIGHT_TOP_SHORT',  ErrorTypes.DEVICE_ERROR,  'Right top short error',  critical_error=True,  device_online=True,  ),  '11917000': ResponseInfo(  'BYPASS_NTC_RIGHT_TOP_OPEN',  ErrorTypes.DEVICE_ERROR,  'Right top open error',  critical_error=True,  device_online=True,  ),  '11918000': ResponseInfo(  'BYPASS_NTC_BOTTOM_SHORT',  ErrorTypes.DEVICE_ERROR,  'Bottom short error',  critical_error=True,  device_online=True,  ),  '11919000': ResponseInfo(  'BYPASS_NTC_BOTTOM_OPEN',  ErrorTypes.DEVICE_ERROR,  'Bottom open error',  critical_error=True,  device_online=True,  ),  '11924000': ResponseInfo(  'BYPASS_RIGHT_TEMP_FAULT',  ErrorTypes.DEVICE_ERROR,  'Right temperature fault',  critical_error=True,  device_online=True,  ),  '11925000': ResponseInfo(  'BYPASS_ZONE_2_MOTOR_ABNORMAL',  ErrorTypes.DEVICE_ERROR,  'Zone 2 motor error',  critical_error=True,  device_online=True,  ),  '11021000': ResponseInfo(  'BYPASS_DEVICE_END',  ErrorTypes.DEVICE_ERROR,  'Device end error',  critical_error=True,  device_online=True,  ),  '11012000': ResponseInfo(  'BYPASS_DEVICE_RUNNING',  ErrorTypes.DEVICE_ERROR,  'Device running error',  critical_error=True,  device_online=True,  ),  '11020000': ResponseInfo(  'BYPASS_DEVICE_STOP',  ErrorTypes.DEVICE_ERROR,  'Device stop error',  device_online=True,  critical_error=True,  ),  '11901000': ResponseInfo(  'BYPASS_DOOR_OPEN',  ErrorTypes.DEVICE_ERROR,  'Door open error',  critical_error=True,  device_online=True,  ),  '11006000': ResponseInfo(  'BYPASS_E1_OPEN',  ErrorTypes.DEVICE_ERROR,  'Open circuit error',  critical_error=True,  device_online=True,  ),  '11007000': ResponseInfo(  'BYPASS_E2_SHORT',  ErrorTypes.DEVICE_ERROR,  'Short circuit error',  device_online=True,  critical_error=True,  ),  '11015000': ResponseInfo(  'BYPASS_E3_WARM',  ErrorTypes.DEVICE_ERROR,  'Warm error',  critical_error=True,  device_online=True,  ),  '11018000': ResponseInfo(  'BYPASS_SET_MIST_LEVEL',  ErrorTypes.DEVICE_ERROR,  'Cannot set mist level error',  device_online=True,  ),  '11019000': ResponseInfo(  'BYPASS_E6_VOLTAGE_LOW',  ErrorTypes.DEVICE_ERROR,  'Low voltage error',  critical_error=True,  device_online=True,  ),  '11013000': ResponseInfo(  'BYPASS_E7_VOLTAGE',  ErrorTypes.DEVICE_ERROR,  'Voltage error',  critical_error=True,  device_online=True,  ),  '11607000': ResponseInfo(  'BYPASS_HUMIDIFIER_ERROR_CONNECT_MSG',  ErrorTypes.DEVICE_ERROR,  'Humidifier connect message error',  ),  '11317000': ResponseInfo(  'BYPASS_DIMMER_NCT',  ErrorTypes.DEVICE_ERROR,  'Dimmer NCT error',  critical_error=True,  device_online=True,  ),  '11608000': ResponseInfo(  'BYPASS_HUMIDIFIER_ERROR_WATER_PUMP',  ErrorTypes.DEVICE_ERROR,  'Humidifier water pump error',  critical_error=True,  device_online=True,  ),  '11609000': ResponseInfo(  'BYPASS_HUMIDIFIER_ERROR_FAN_MOTOR',  ErrorTypes.DEVICE_ERROR,  'Humidifier fan motor error',  critical_error=True,  device_online=True,  ),  '11601000': ResponseInfo(  'BYPASS_HUMIDIFIER_ERROR_DRY_BURNING',  ErrorTypes.DEVICE_ERROR,  'Dry burning error',  critical_error=True,  device_online=True,  ),  '11602000': ResponseInfo(  'BYPASS_HUMIDIFIER_ERROR_PTC',  ErrorTypes.DEVICE_ERROR,  'Humidifier PTC error',  critical_error=True,  device_online=True,  ),  '11603000': ResponseInfo(  'BYPASS_HUMIDIFIER_ERROR_WARM_HIGH',  ErrorTypes.DEVICE_ERROR,  'Humidifier warm high error',  critical_error=True,  device_online=True,  ),  '11604000': ResponseInfo(  'BYPASS_HUMIDIFIER_ERROR_WATER',  ErrorTypes.DEVICE_ERROR,  'Humidifier water error',  critical_error=True,  device_online=True,  ),  '11907000': ResponseInfo(  'BYPASS_LOW_WATER',  ErrorTypes.DEVICE_ERROR,  'Low water error',  device_online=True,  critical_error=True,  ),  '11028000': ResponseInfo(  'BYPASS_MOTOR_OPEN',  ErrorTypes.DEVICE_ERROR,  'Motor open error',  device_online=True,  critical_error=True,  ),  '11017000': ResponseInfo(  'BYPASS_NOT_SUPPORTED', ErrorTypes.REQUEST_ERROR, 'Not supported error'  ),  '11905000': ResponseInfo(  'BYPASS_NO_POT',  ErrorTypes.DEVICE_ERROR,  'No pot error',  device_online=True,  critical_error=True,  ),  '12001000': ResponseInfo(  'BYPASS_LACK_FOOD',  ErrorTypes.DEVICE_ERROR,  'Lack of food error',  device_online=True,  critical_error=True,  ),  '12002000': ResponseInfo(  'BYPASS_JAM_FOOD',  ErrorTypes.DEVICE_ERROR,  'Jam food error',  device_online=True,  critical_error=True,  ),  '12003000': ResponseInfo(  'BYPASS_BLOCK_FOOD',  ErrorTypes.DEVICE_ERROR,  'Block food error',  device_online=True,  critical_error=True,  ),  '12004000': ResponseInfo(  'BYPASS_PUMP_FAIL',  ErrorTypes.DEVICE_ERROR,  'Pump failure error',  device_online=True,  critical_error=True,  ),  '12005000': ResponseInfo(  'BYPASS_CALI_FAIL',  ErrorTypes.DEVICE_ERROR,  'Calibration failure error',  device_online=True,  critical_error=True,  ),  '11611000': ResponseInfo(  'BYPASS_FILTER_TRAY_ERROR',  ErrorTypes.DEVICE_ERROR,  'Filter tray error',  critical_error=True,  device_online=True,  ),  '11610000': ResponseInfo(  'BYPASS_VALUE_ERROR',  ErrorTypes.DEVICE_ERROR,  'Value error',  critical_error=True,  device_online=True,  ),  '11022000': ResponseInfo(  'BYPASS_CANNOT_SET_LEVEL',  ErrorTypes.DEVICE_ERROR,  'Cannot set level error',  critical_error=False,  device_online=True,  ),  '11023000': ResponseInfo(  'BYPASS_NTC_BOTTOM_OPEN',  ErrorTypes.DEVICE_ERROR,  'NTC bottom open error',  critical_error=True,  device_online=True,  ),  '11024000': ResponseInfo(  'BYPASS_NTC_BOTTOM_SHORT',  ErrorTypes.DEVICE_ERROR,  'NTC bottom short error',  critical_error=True,  device_online=True,  ),  '11026000': ResponseInfo(  'BYPASS_NTC_TOP_OPEN',  ErrorTypes.DEVICE_ERROR,  'NTC top open error',  critical_error=True,  device_online=True,  ),  '11025000': ResponseInfo(  'BYPASS_NTC_TOP_SHORT',  ErrorTypes.DEVICE_ERROR,  'NTC top short error',  critical_error=True,  device_online=True,  ),  '11027000': ResponseInfo(  'BYPASS_OPEN_HEAT_PIPE_OR_OPEN_FUSE',  ErrorTypes.DEVICE_ERROR,  'Open heat pipe or fuse error',  critical_error=True,  device_online=True,  ),  '11906000': ResponseInfo(  'BYPASS_OVER_HEATED',  ErrorTypes.DEVICE_ERROR,  'Overheated error',  critical_error=True,  device_online=True,  ),  '11000000': ResponseInfo(  'BYPASS_PARAMETER_INVALID',  ErrorTypes.REQUEST_ERROR,  'Invalid bypass parameter',  ),  '11510000': ResponseInfo(  'BYPASS_SCHEDULE_CONFLICT', ErrorTypes.CONFIG_ERROR, 'Schedule conflict'  ),  '11502000': ResponseInfo(  'BYPASS_SCHEDULE_MAX',  ErrorTypes.CONFIG_ERROR,  'Maximum number of schedules reached',  ),  '11507000': ResponseInfo(  'BYPASS_SCHEDULE_NOT_EXIST',  ErrorTypes.CONFIG_ERROR,  'Schedule does not exist',  ),  '11503000': ResponseInfo(  'TIMER_MAX',  ErrorTypes.CONFIG_ERROR,  'Maximum number of timers reached',  ),  '11508000': ResponseInfo(  'TIMER_NOT_EXIST',  ErrorTypes.CONFIG_ERROR,  'Timer does not exist',  ),  '11605000': ResponseInfo(  'BYPASS_WATER_LOCK',  ErrorTypes.DEVICE_ERROR,  'Water lock error',  critical_error=True,  device_online=True,  ),  '11029000': ResponseInfo(  'BYPASS_WIFI_ERROR', ErrorTypes.DEVICE_ERROR, 'WiFi error'  ),  '11902000': ResponseInfo(  'BY_PASS_ERROR_COOKING_158',  ErrorTypes.DEVICE_ERROR,  'Error setting cook mode, air fryer is already cooking',  device_online=True,  ),  '11035000': ResponseInfo(  'BYPASS_MOTOR_ABNORMAL_ERROR',  ErrorTypes.DEVICE_ERROR,  'Motor abnormal error',  critical_error=True,  device_online=True,  ),  '11903000': ResponseInfo(  'BY_PASS_ERROR_NOT_COOK_158',  ErrorTypes.DEVICE_ERROR,  'Error pausing, air fryer is not cooking',  device_online=True,  ),  '-12001000': ResponseInfo(  'CONFIGKEY_EXPIRED', ErrorTypes.CONFIG_ERROR, 'Configkey expired'  ),  '-12000000': ResponseInfo(  'CONFIGKEY_NOT_EXIST',  ErrorTypes.CONFIG_ERROR,  'Configkey does not exist',  ),  '-11305000': ResponseInfo(  'CONFIG_MODULE_NOT_EXIST',  ErrorTypes.REQUEST_ERROR,  'Config module does not exist',  ),  '-11100000': ResponseInfo(  'DATABASE_FAILED', ErrorTypes.SERVER_ERROR, 'Database error'  ),  '-11101000': ResponseInfo(  'DATABASE_FAILED_ERROR', ErrorTypes.SERVER_ERROR, 'Database error'  ),  '-11306000': ResponseInfo(  'DEVICE_BOUND',  ErrorTypes.CONFIG_ERROR,  'Device already associated with another account',  ),  '-11301000': ResponseInfo(  'DEVICE_NOT_EXIST',  ErrorTypes.CONFIG_ERROR,  'Device does not exist',  device_online=False,  ),  '-11300000': ResponseInfo(  'DEVICE_OFFLINE',  ErrorTypes.DEVICE_OFFLINE,  'Device offline',  device_online=False,  ),  '-11302000': ResponseInfo(  'DEVICE_TIMEOUT',  ErrorTypes.DEVICE_ERROR,  'Device timeout',  device_online=False,  ),  '-11304000': ResponseInfo(  'DEVICE_TIMEZONE_DIFF',  ErrorTypes.CONFIG_ERROR,  'Device timezone difference',  ),  '-11303000': ResponseInfo(  'FIRMWARE_LATEST',  ErrorTypes.CONFIG_ERROR,  'No firmware update available',  ),  '-11102000': ResponseInfo(  'INTERNAL_ERROR', ErrorTypes.SERVER_ERROR, 'Internal server error'  ),  '-11004000': ResponseInfo(  'METHOD_NOT_FOUND', ErrorTypes.REQUEST_ERROR, 'Method not found'  ),  '-11107000': ResponseInfo(  'MONGODB_ERROR', ErrorTypes.SERVER_ERROR, 'MongoDB error'  ),  '-11105000': ResponseInfo(  'MYSQL_ERROR', ErrorTypes.SERVER_ERROR, 'MySQL error'  ),  '88888888': ResponseInfo(  'NETWORK_DISABLE', ErrorTypes.SERVER_ERROR, 'Network disabled'  ),  '77777777': ResponseInfo(  'NETWORK_TIMEOUT', ErrorTypes.SERVER_ERROR, 'Network timeout'  ),  '4031005': ResponseInfo(  'NO_PERMISSION_7A', ErrorTypes.DEVICE_ERROR, 'No 7A Permissions'  ),  '-11201000': ResponseInfo(  'PASSWORD_ERROR', ErrorTypes.AUTHENTICATION, 'Invalid password'  ),  '-11901000': ResponseInfo(  'PID_NOT_EXIST', ErrorTypes.DEVICE_ERROR, 'PID does not exist'  ),  '-11106000': ResponseInfo(  'REDIS_ERROR', ErrorTypes.SERVER_ERROR, 'Redis error'  ),  '-11003000': ResponseInfo(  'REQUEST_HIGH', ErrorTypes.RATE_LIMIT, 'Rate limiting error'  ),  '-11005000': ResponseInfo(  'RESOURCE_NOT_EXIST',  ErrorTypes.REQUEST_ERROR,  'No device with ID found',  device_online=False,  ),  '-11108000': ResponseInfo('S3_ERROR', ErrorTypes.SERVER_ERROR, 'S3 error'),  '-11502000': ResponseInfo(  'SCHEDULE_MAX',  ErrorTypes.CONFIG_ERROR,  'Maximum number of schedules reached',  ),  '-11103000': ResponseInfo(  'SERVER_BUSY', ErrorTypes.SERVER_ERROR, 'Server busy'  ),  '-11104000': ResponseInfo(  'SERVER_TIMEOUT', ErrorTypes.SERVER_ERROR, 'Server timeout'  ),  '-11501000': ResponseInfo(  'TIMER_CONFLICT', ErrorTypes.DEVICE_ERROR, 'Timer conflict'  ),  '-11503000': ResponseInfo(  'TIMER_MAX', ErrorTypes.DEVICE_ERROR, 'Maximum number of timers reached'  ),  '-11500000': ResponseInfo(  'TIMER_NOT_EXIST', ErrorTypes.DEVICE_ERROR, 'Timer does not exist'  ),  '-11001000': ResponseInfo(  'TOKEN_EXPIRED', ErrorTypes.TOKEN_ERROR, 'Invalid token'  ),  '-999999999': ResponseInfo(  'UNKNOWN', ErrorTypes.UNKNOWN_ERROR, 'Unknown error'  ),  '-11307000': ResponseInfo(  'UUID_NOT_EXIST',  ErrorTypes.DEVICE_ERROR,  'Device UUID not found',  device_online=False,  ),  '12102000': ResponseInfo(  'TEM_SENOR_ERROR',  ErrorTypes.DEVICE_ERROR,  'Temperature sensor error',  critical_error=True,  device_online=True,  ),  '12103000': ResponseInfo(  'HUM_SENOR_ERROR',  ErrorTypes.DEVICE_ERROR,  'Humidity sensor error',  critical_error=True,  device_online=True,  ),  '12101000': ResponseInfo(  'SENSOR_ERROR',  ErrorTypes.DEVICE_ERROR,  'Sensor error',  critical_error=True,  device_online=True,  ),  '11005000': ResponseInfo(  'BYPASS_DEVICE_IS_OFF',  ErrorTypes.DEVICE_ERROR,  'Device is offDevice is off',  critical_error=True,  device_online=True,  ),  }  )   @classmethod  def get_error_info(  cls, error_code: str | int | None, msg: str | None = None  ) -> ResponseInfo:  """Return error dictionary for the given error code.   Args:  error_code (str | int): Error code to lookup.  msg: (str | None): Optional message from API.   Returns:  dict: Error dictionary for the given error code.   Example:  ```python  ErrorCodes.get_error_info("-11201022")  ErrorInfo(  "PASSWORD_ERROR", ErrorTypes.AUTHENTICATION, "Invalid password"  )  ```  """  try:  if error_code is None:  error_code = '-999999999'  error_str = str(error_code)  error_int = int(error_code)  if error_str == '0':  error_info = ResponseInfo('SUCCESS', ErrorTypes.SUCCESS, 'Success')  elif error_str in cls.errors:  error_info = cls.errors[error_str]  else:  error_code = int(error_int / 1000) * 1000  error_info = cls.errors[str(error_code)]   error_info = replace(error_info)  if msg is not None:  error_info.message = f'{error_info.message} - {msg}'  error_info.code = error_int   except (ValueError, TypeError, KeyError):  error_info = ResponseInfo(  'UNKNOWN', ErrorTypes.UNKNOWN_ERROR, 'Unknown error'  )   return error_info   @classmethod  def is_critical(cls, error_code: str | int) -> bool:  """Check if error code is a device error.   Args:  error_code (str | int): Error code to check.   Returns:  bool: True if error code is a device error, False otherwise.  """  error_info = cls.get_error_info(error_code)  return bool(error_info.critical_error) 

get_error_info classmethod

get_error_info(  error_code: str | int | None, msg: str | None = None ) -> ResponseInfo 

Return error dictionary for the given error code.

Parameters:

Name Type Description Default

error_code

str | int

Error code to lookup.

required

msg

str | None

(str | None): Optional message from API.

None

Returns:

Name Type Description
dict ResponseInfo

Error dictionary for the given error code.

Example
ErrorCodes.get_error_info("-11201022") ErrorInfo(  "PASSWORD_ERROR", ErrorTypes.AUTHENTICATION, "Invalid password" ) 
Source code in src/pyvesync/utils/errors.py
@classmethod def get_error_info(  cls, error_code: str | int | None, msg: str | None = None ) -> ResponseInfo:  """Return error dictionary for the given error code.   Args:  error_code (str | int): Error code to lookup.  msg: (str | None): Optional message from API.   Returns:  dict: Error dictionary for the given error code.   Example:  ```python  ErrorCodes.get_error_info("-11201022")  ErrorInfo(  "PASSWORD_ERROR", ErrorTypes.AUTHENTICATION, "Invalid password"  )  ```  """  try:  if error_code is None:  error_code = '-999999999'  error_str = str(error_code)  error_int = int(error_code)  if error_str == '0':  error_info = ResponseInfo('SUCCESS', ErrorTypes.SUCCESS, 'Success')  elif error_str in cls.errors:  error_info = cls.errors[error_str]  else:  error_code = int(error_int / 1000) * 1000  error_info = cls.errors[str(error_code)]   error_info = replace(error_info)  if msg is not None:  error_info.message = f'{error_info.message} - {msg}'  error_info.code = error_int   except (ValueError, TypeError, KeyError):  error_info = ResponseInfo(  'UNKNOWN', ErrorTypes.UNKNOWN_ERROR, 'Unknown error'  )   return error_info 

is_critical classmethod

is_critical(error_code: str | int) -> bool 

Check if error code is a device error.

Parameters:

Name Type Description Default

error_code

str | int

Error code to check.

required

Returns:

Name Type Description
bool bool

True if error code is a device error, False otherwise.

Source code in src/pyvesync/utils/errors.py
@classmethod def is_critical(cls, error_code: str | int) -> bool:  """Check if error code is a device error.   Args:  error_code (str | int): Error code to check.   Returns:  bool: True if error code is a device error, False otherwise.  """  error_info = cls.get_error_info(error_code)  return bool(error_info.critical_error) 

pyvesync.utils.errors.raise_api_errors

raise_api_errors(error_info: ResponseInfo) -> None 

Raise the appropriate exception for API error code.

Called by VeSync.async_call_api method.

Raises:

Type Description
VeSyncRateLimitError

Rate limit error

VeSyncLoginError

Authentication error

VeSyncTokenError

Token error

VeSyncServerError

Server error

Source code in src/pyvesync/utils/errors.py
def raise_api_errors(error_info: ResponseInfo) -> None:  """Raise the appropriate exception for API error code.   Called by `VeSync.async_call_api` method.   Raises:  VeSyncRateLimitError: Rate limit error  VeSyncLoginError: Authentication error  VeSyncTokenError: Token error  VeSyncServerError: Server error  """  match error_info.error_type:  case ErrorTypes.RATE_LIMIT:  raise VeSyncRateLimitError  case ErrorTypes.AUTHENTICATION:  raise VeSyncLoginError(error_info.message)  case ErrorTypes.SERVER_ERROR:  msg = (  f'{error_info.message} - '  'Please report error to github.com/webdjoe/pyvesync/issues'  )  raise VeSyncServerError(msg) 

VeSync Exceptions

pyvesync.utils.errors.VeSyncError

Bases: Exception

Base exception for VeSync errors.

These are raised based on API response codes and exceptions that may be raised by the different handlers.

Source code in src/pyvesync/utils/errors.py
class VeSyncError(Exception):  """Base exception for VeSync errors.   These are raised based on API response codes and exceptions  that may be raised by the different handlers.  """ 

pyvesync.utils.errors.VeSyncLoginError

Bases: VeSyncError

Exception raised for login authentication errors.

Source code in src/pyvesync/utils/errors.py
class VeSyncLoginError(VeSyncError):  """Exception raised for login authentication errors."""   def __init__(self, msg: str) -> None:  """Initialize the exception with a message."""  super().__init__(msg) 

pyvesync.utils.errors.VeSyncTokenError

Bases: VeSyncError

Exception raised for VeSync API authentication errors.

Source code in src/pyvesync/utils/errors.py
class VeSyncTokenError(VeSyncError):  """Exception raised for VeSync API authentication errors."""   def __init__(self, msg: str | None = None) -> None:  """Initialize the exception with a message."""  if msg is None or msg.strip() == '':  msg = 'Re-authentication required'  super().__init__(f'Token expired or invalid - {msg}') 

pyvesync.utils.errors.VeSyncServerError

Bases: VeSyncError

Exception raised for VeSync API server errors.

Source code in src/pyvesync/utils/errors.py
class VeSyncServerError(VeSyncError):  """Exception raised for VeSync API server errors."""   def __init__(self, msg: str) -> None:  """Initialize the exception with a message."""  super().__init__(msg) 

pyvesync.utils.errors.VeSyncRateLimitError

Bases: VeSyncError

Exception raised for VeSync API rate limit errors.

Source code in src/pyvesync/utils/errors.py
class VeSyncRateLimitError(VeSyncError):  """Exception raised for VeSync API rate limit errors."""   def __init__(self) -> None:  """Initialize the exception with a message."""  super().__init__('VeSync API rate limit exceeded') 

pyvesync.utils.errors.VeSyncAPIResponseError

Bases: VeSyncError

Exception raised for malformed VeSync API responses.

Source code in src/pyvesync/utils/errors.py
class VeSyncAPIResponseError(VeSyncError):  """Exception raised for malformed VeSync API responses."""   def __init__(self, msg: None | str = None) -> None:  """Initialize the exception with a message."""  if msg is None:  msg = 'Unexpected VeSync API response.'  super().__init__(msg) 

pyvesync.utils.errors.VeSyncAPIStatusCodeError

Bases: VeSyncError

Exception raised for malformed VeSync API responses.

Source code in src/pyvesync/utils/errors.py
class VeSyncAPIStatusCodeError(VeSyncError):  """Exception raised for malformed VeSync API responses."""   def __init__(self, status_code: str | None = None) -> None:  """Initialize the exception with a message."""  message = 'VeSync API returned an unknown status code'  if status_code is not None:  message = f'VeSync API returned status code {status_code}'  super().__init__(message)