const.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. IO_METER = "WoIOSensorTH"
  32. MOTION_SENSOR = "WoPresence"
  33. COLOR_BULB = "WoBulb"
  34. CEILING_LIGHT = "WoCeiling"
  35. LOCK = "WoLock"
  36. LOCK_PRO = "WoLockPro"
  37. BLIND_TILT = "WoBlindTilt"
  38. HUB2 = "WoHub2"
  39. class LockStatus(Enum):
  40. LOCKED = 0
  41. UNLOCKED = 1
  42. LOCKING = 2
  43. UNLOCKING = 3
  44. LOCKING_STOP = 4 # LOCKING_BLOCKED
  45. UNLOCKING_STOP = 5 # UNLOCKING_BLOCKED
  46. NOT_FULLY_LOCKED = 6 # LATCH_LOCKED - Only EU lock type