fan.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from __future__ import annotations
  2. from enum import Enum
  3. class FanMode(Enum):
  4. NORMAL = 1
  5. NATURAL = 2
  6. SLEEP = 3
  7. BABY = 4
  8. @classmethod
  9. def get_modes(cls) -> list[str]:
  10. return [mode.name.lower() for mode in cls]
  11. class StandingFanMode(Enum):
  12. NORMAL = 1
  13. NATURAL = 2
  14. SLEEP = 3
  15. BABY = 4
  16. CUSTOM_NATURAL = 5
  17. @classmethod
  18. def get_modes(cls) -> list[str]:
  19. return [mode.name.lower() for mode in cls]
  20. class CirculatorFanProMode(Enum):
  21. """
  22. Circulator Fan Pro (W1160) running modes.
  23. Mode 0x04 is hurricane, not the baby mode of the legacy fan.
  24. """
  25. NORMAL = 1
  26. NATURAL = 2
  27. SLEEP = 3
  28. HURRICANE = 4
  29. @classmethod
  30. def get_modes(cls) -> list[str]:
  31. return [mode.name.lower() for mode in cls]
  32. class NightLightState(Enum):
  33. """Standing Fan night-light command values."""
  34. LEVEL_1 = 1
  35. LEVEL_2 = 2
  36. OFF = 3
  37. class HorizontalOscillationAngle(Enum):
  38. """
  39. Horizontal oscillation angle command values.
  40. For the horizontal axis the device byte is the same as the
  41. user-facing angle in degrees.
  42. """
  43. ANGLE_30 = 30
  44. ANGLE_60 = 60
  45. ANGLE_90 = 90
  46. class VerticalOscillationAngle(Enum):
  47. """
  48. Vertical oscillation angle command values.
  49. The Standing Fan uses a different byte encoding on the vertical axis
  50. than on the horizontal one. Byte 0x5A (decimal 90) is interpreted as
  51. an axis halt, so 90° maps to byte 0x5F (95). 30° and 60° match their
  52. degree values.
  53. """
  54. ANGLE_30 = 30
  55. ANGLE_60 = 60
  56. ANGLE_90 = 95
  57. @classmethod
  58. def _missing_(cls, value: int) -> VerticalOscillationAngle | None:
  59. if value == 90:
  60. return cls.ANGLE_90
  61. return None