const.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. """Library to handle connection with Switchbot."""
  2. from __future__ import annotations
  3. from enum import Enum
  4. from .enum import StrEnum
  5. DEFAULT_RETRY_COUNT = 3
  6. DEFAULT_RETRY_TIMEOUT = 1
  7. DEFAULT_SCAN_TIMEOUT = 5
  8. class SwitchbotApiError(RuntimeError):
  9. """Raised when API call fails.
  10. This exception inherits from RuntimeError to avoid breaking existing code
  11. but will be changed to Exception in a future release.
  12. """
  13. class SwitchbotAuthenticationError(RuntimeError):
  14. """Raised when authentication fails.
  15. This exception inherits from RuntimeError to avoid breaking existing code
  16. but will be changed to Exception in a future release.
  17. """
  18. class SwitchbotAccountConnectionError(RuntimeError):
  19. """Raised when connection to Switchbot account fails.
  20. This exception inherits from RuntimeError to avoid breaking existing code
  21. but will be changed to Exception in a future release.
  22. """
  23. class SwitchbotModel(StrEnum):
  24. BOT = "WoHand"
  25. CURTAIN = "WoCurtain"
  26. HUMIDIFIER = "WoHumi"
  27. PLUG_MINI = "WoPlug"
  28. CONTACT_SENSOR = "WoContact"
  29. LIGHT_STRIP = "WoStrip"
  30. METER = "WoSensorTH"
  31. METER_PRO = "WoTHP"
  32. METER_PRO_C = "WoTHPc"
  33. IO_METER = "WoIOSensorTH"
  34. MOTION_SENSOR = "WoPresence"
  35. COLOR_BULB = "WoBulb"
  36. CEILING_LIGHT = "WoCeiling"
  37. LOCK = "WoLock"
  38. LOCK_PRO = "WoLockPro"
  39. BLIND_TILT = "WoBlindTilt"
  40. HUB2 = "WoHub2"
  41. LEAK = "Leak Detector"
  42. KEYPAD = "WoKeypad"
  43. RELAY_SWITCH_1PM = "Relay Switch 1PM"
  44. RELAY_SWITCH_1 = "Relay Switch 1"
  45. class LockStatus(Enum):
  46. LOCKED = 0
  47. UNLOCKED = 1
  48. LOCKING = 2
  49. UNLOCKING = 3
  50. LOCKING_STOP = 4 # LOCKING_BLOCKED
  51. UNLOCKING_STOP = 5 # UNLOCKING_BLOCKED
  52. NOT_FULLY_LOCKED = 6 # LATCH_LOCKED - Only EU lock type