|
| 1 | +"""Scneider Electric Smoke Alarm.""" |
| 2 | + |
| 3 | +from typing import Final |
| 4 | + |
| 5 | +from zigpy.quirks import CustomCluster |
| 6 | +from zigpy.quirks.v2 import EntityType, QuirkBuilder, ReportingConfig |
| 7 | +from zigpy.quirks.v2.homeassistant import UnitOfTime |
| 8 | +from zigpy.quirks.v2.homeassistant.number import NumberDeviceClass |
| 9 | +import zigpy.types as t |
| 10 | +from zigpy.zcl.foundation import ZCLAttributeDef |
| 11 | + |
| 12 | +from zhaquirks.schneiderelectric import SE_MANUF_NAME, SEBasic |
| 13 | + |
| 14 | + |
| 15 | +class SELEDBrightness(t.enum8): |
| 16 | + """LED brightness.""" |
| 17 | + |
| 18 | + Min = 0x00 |
| 19 | + Max = 0x01 |
| 20 | + |
| 21 | + |
| 22 | +class SEAlarmSoundLevel(t.enum8): |
| 23 | + """Alarm sound level.""" |
| 24 | + |
| 25 | + Min = 0x00 |
| 26 | + Max = 0x01 |
| 27 | + |
| 28 | + |
| 29 | +class SEAlarmSoundMode(t.enum8): |
| 30 | + """Alarm sound mode.""" |
| 31 | + |
| 32 | + PressureLow = 0x00 |
| 33 | + PressureMid = 0x01 |
| 34 | + PressureHigh = 0x02 |
| 35 | + |
| 36 | + |
| 37 | +class SEAlarmConfiguration(CustomCluster): |
| 38 | + """Schneider Electric Alarm Configuration cluster.""" |
| 39 | + |
| 40 | + cluster_id = 0xFC04 |
| 41 | + name = "SEAlarmConfiguration" |
| 42 | + |
| 43 | + class AttributeDefs(CustomCluster.AttributeDefs): |
| 44 | + """Attribute definitions.""" |
| 45 | + |
| 46 | + se_led_brightness: Final = ZCLAttributeDef( |
| 47 | + id=0x0000, |
| 48 | + type=SELEDBrightness, |
| 49 | + access="rw", |
| 50 | + is_manufacturer_specific=True, |
| 51 | + ) |
| 52 | + se_alarm_sound_level: Final = ZCLAttributeDef( |
| 53 | + id=0x0001, |
| 54 | + type=SEAlarmSoundLevel, |
| 55 | + access="rw", |
| 56 | + is_manufacturer_specific=True, |
| 57 | + ) |
| 58 | + se_alarm_sound_mode: Final = ZCLAttributeDef( |
| 59 | + id=0x0002, |
| 60 | + type=SEAlarmSoundMode, |
| 61 | + access="rw", |
| 62 | + is_manufacturer_specific=True, |
| 63 | + ) |
| 64 | + se_lifetime: Final = ZCLAttributeDef( |
| 65 | + id=0x0003, |
| 66 | + type=t.uint8_t, |
| 67 | + access="r", |
| 68 | + is_manufacturer_specific=True, |
| 69 | + ) |
| 70 | + se_hush_duration: Final = ZCLAttributeDef( |
| 71 | + id=0x0004, |
| 72 | + type=t.uint8_t, |
| 73 | + access="rw", |
| 74 | + is_manufacturer_specific=True, |
| 75 | + ) |
| 76 | + se_test_mode: Final = ZCLAttributeDef( |
| 77 | + id=0x0005, |
| 78 | + type=t.Bool, |
| 79 | + access="rw", |
| 80 | + is_manufacturer_specific=True, |
| 81 | + ) |
| 82 | + se_silence_alarm: Final = ZCLAttributeDef( |
| 83 | + id=0x0006, |
| 84 | + type=t.Bool, |
| 85 | + access="rw", |
| 86 | + is_manufacturer_specific=True, |
| 87 | + ) |
| 88 | + se_cluster_revision: Final = ZCLAttributeDef( |
| 89 | + id=0xFFFD, |
| 90 | + type=t.uint16_t, |
| 91 | + access="r", |
| 92 | + is_manufacturer_specific=True, |
| 93 | + ) |
| 94 | + |
| 95 | + |
| 96 | +( |
| 97 | + QuirkBuilder(SE_MANUF_NAME, "W599001") |
| 98 | + .applies_to(SE_MANUF_NAME, "W599501") |
| 99 | + .applies_to(SE_MANUF_NAME, "755WSA") |
| 100 | + .replaces(SEBasic, endpoint_id=20) |
| 101 | + .replaces(SEAlarmConfiguration, endpoint_id=20) |
| 102 | + .enum( |
| 103 | + cluster_id=SEAlarmConfiguration.cluster_id, |
| 104 | + endpoint_id=20, |
| 105 | + attribute_name=SEAlarmConfiguration.AttributeDefs.se_led_brightness.name, |
| 106 | + translation_key="led_brightness", |
| 107 | + fallback_name="LED brightness", |
| 108 | + enum_class=SELEDBrightness, |
| 109 | + ) |
| 110 | + .enum( |
| 111 | + cluster_id=SEAlarmConfiguration.cluster_id, |
| 112 | + endpoint_id=20, |
| 113 | + attribute_name=SEAlarmConfiguration.AttributeDefs.se_alarm_sound_level.name, |
| 114 | + translation_key="alarm_sound_level", |
| 115 | + fallback_name="Alarm sound level", |
| 116 | + enum_class=SEAlarmSoundLevel, |
| 117 | + ) |
| 118 | + .enum( |
| 119 | + cluster_id=SEAlarmConfiguration.cluster_id, |
| 120 | + endpoint_id=20, |
| 121 | + attribute_name=SEAlarmConfiguration.AttributeDefs.se_alarm_sound_mode.name, |
| 122 | + translation_key="alarm_sound_mode", |
| 123 | + fallback_name="Alarm sound mode", |
| 124 | + enum_class=SEAlarmSoundMode, |
| 125 | + ) |
| 126 | + .sensor( |
| 127 | + cluster_id=SEAlarmConfiguration.cluster_id, |
| 128 | + endpoint_id=20, |
| 129 | + attribute_name=SEAlarmConfiguration.AttributeDefs.se_lifetime.name, |
| 130 | + translation_key="lifetime", |
| 131 | + fallback_name="Lifetime", |
| 132 | + unit=UnitOfTime.YEARS, |
| 133 | + multiplier=0.5, |
| 134 | + entity_type=EntityType.DIAGNOSTIC, |
| 135 | + ) |
| 136 | + .number( |
| 137 | + cluster_id=SEAlarmConfiguration.cluster_id, |
| 138 | + endpoint_id=20, |
| 139 | + attribute_name=SEAlarmConfiguration.AttributeDefs.se_hush_duration.name, |
| 140 | + translation_key="hush_duration", |
| 141 | + fallback_name="Hush duration", |
| 142 | + device_class=NumberDeviceClass.DURATION, |
| 143 | + unit=UnitOfTime.MINUTES, |
| 144 | + min_value=5, |
| 145 | + max_value=15, |
| 146 | + step=1, |
| 147 | + ) |
| 148 | + .switch( |
| 149 | + cluster_id=SEAlarmConfiguration.cluster_id, |
| 150 | + endpoint_id=20, |
| 151 | + attribute_name=SEAlarmConfiguration.AttributeDefs.se_test_mode.name, |
| 152 | + translation_key="test_mode", |
| 153 | + fallback_name="Test mode", |
| 154 | + reporting_config=ReportingConfig( |
| 155 | + min_interval=0, |
| 156 | + max_interval=0, |
| 157 | + reportable_change=1, |
| 158 | + ), |
| 159 | + ) |
| 160 | + .switch( |
| 161 | + cluster_id=SEAlarmConfiguration.cluster_id, |
| 162 | + endpoint_id=20, |
| 163 | + attribute_name=SEAlarmConfiguration.AttributeDefs.se_silence_alarm.name, |
| 164 | + translation_key="silence_alarm", |
| 165 | + fallback_name="Silence alarm", |
| 166 | + reporting_config=ReportingConfig( |
| 167 | + min_interval=0, |
| 168 | + max_interval=0, |
| 169 | + reportable_change=1, |
| 170 | + ), |
| 171 | + ) |
| 172 | + .add_to_registry() |
| 173 | +) |
0 commit comments