motion.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. """Third Reality Motion devices."""
  2. from typing import Final
  3. from zigpy.profiles import zha # type: ignore
  4. from zigpy.quirks import CustomDevice # type: ignore
  5. import zigpy.types as t # type: ignore
  6. from zigpy.zcl.clusters.general import Basic, Ota, PowerConfiguration # type: ignore
  7. from zigpy.zcl.clusters.security import IasZone # type: ignore
  8. from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef # type: ignore
  9. from zhaquirks import CustomCluster # type: ignore
  10. from zhaquirks.const import ( # type: ignore
  11. DEVICE_TYPE,
  12. ENDPOINTS,
  13. INPUT_CLUSTERS,
  14. MODELS_INFO,
  15. OUTPUT_CLUSTERS,
  16. PROFILE_ID,
  17. )
  18. from zhaquirks.thirdreality import THIRD_REALITY # type: ignore
  19. THIRD_REALITY_MOTION_BRIGHTNESS_CLUSTER_ID = 0xFF00
  20. THIRD_REALITY_MOTION_DELAY_CLUSTER_ID = 0xFF01
  21. class ControlMode(t.uint16_t): # noqa: D101
  22. pass
  23. class ThirdRealityMotionCluster(CustomCluster):
  24. """ThirdReality Acceleration Cluster."""
  25. cluster_id = THIRD_REALITY_MOTION_DELAY_CLUSTER_ID
  26. class AttributeDefs(BaseAttributeDefs):
  27. """Attribute definitions."""
  28. cool_down_time: Final = ZCLAttributeDef(
  29. id=0x0001,
  30. type=ControlMode,
  31. is_manufacturer_specific=True,
  32. )
  33. class ThirdRealityMotionBrightnessCluster(CustomCluster):
  34. """ThirdReality Acceleration Cluster."""
  35. cluster_id = THIRD_REALITY_MOTION_BRIGHTNESS_CLUSTER_ID
  36. class AttributeDefs(BaseAttributeDefs):
  37. """Attribute definitions."""
  38. red_light: Final = ZCLAttributeDef(
  39. id=0x0000,
  40. type=ControlMode,
  41. is_manufacturer_specific=True,
  42. )
  43. blue_light: Final = ZCLAttributeDef(
  44. id=0x0002,
  45. type=ControlMode,
  46. is_manufacturer_specific=True,
  47. )
  48. class Motion(CustomDevice):
  49. """ThirdReality Motion device."""
  50. signature = {
  51. MODELS_INFO: [
  52. (THIRD_REALITY, "3RMS16BZ"),
  53. ],
  54. ENDPOINTS: {
  55. 1: {
  56. PROFILE_ID: zha.PROFILE_ID,
  57. DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
  58. INPUT_CLUSTERS: [
  59. Basic.cluster_id, # 0x0000
  60. PowerConfiguration.cluster_id, # 0x0001
  61. IasZone.cluster_id, # 0x0500
  62. ThirdRealityMotionCluster.cluster_id, # 0xFF01
  63. ThirdRealityMotionBrightnessCluster.cluster_id,
  64. ],
  65. OUTPUT_CLUSTERS: [
  66. Ota.cluster_id, # 0x0019
  67. ],
  68. },
  69. },
  70. }
  71. replacement = {
  72. ENDPOINTS: {
  73. 1: {
  74. PROFILE_ID: zha.PROFILE_ID,
  75. DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
  76. INPUT_CLUSTERS: [
  77. Basic.cluster_id, # 0x0000
  78. PowerConfiguration.cluster_id, # 0x0001
  79. IasZone.cluster_id, # 0x0500
  80. ThirdRealityMotionCluster, # 0xFF01
  81. ThirdRealityMotionBrightnessCluster,
  82. ],
  83. OUTPUT_CLUSTERS: [
  84. Ota.cluster_id, # 0x0019
  85. ],
  86. },
  87. },
  88. }