const.py 1.8 KB

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