|
| 1 | +"""Quirk for Aqara Dimmer Switch H2 EU (lumi.switch.agl011).""" |
| 2 | + |
| 3 | +from zigpy import types |
| 4 | +from zigpy.profiles import zha |
| 5 | +from zigpy.quirks.v2 import QuirkBuilder |
| 6 | +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef |
| 7 | + |
| 8 | +from zhaquirks.xiaomi import DeviceTemperatureCluster, XiaomiAqaraE1Cluster |
| 9 | + |
| 10 | + |
| 11 | +class ModeSwitch(types.enum16): |
| 12 | + """Enum for dimmer mode switch.""" |
| 13 | + |
| 14 | + Quick = 0x01 |
| 15 | + Anti_Flicker = 0x04 |
| 16 | + |
| 17 | + |
| 18 | +class OperationMode(types.enum8): |
| 19 | + """Enum for dimmer operation mode.""" |
| 20 | + |
| 21 | + Decoupled = 0x00 |
| 22 | + Relay = 0x01 |
| 23 | + |
| 24 | + |
| 25 | +class Phase(types.enum8): |
| 26 | + """Enum for dimmer phase.""" |
| 27 | + |
| 28 | + Leading = 0x00 |
| 29 | + Trailing = 0x01 |
| 30 | + |
| 31 | + |
| 32 | +class PowerOnState(types.enum8): |
| 33 | + """Enum for dimmer power-on state.""" |
| 34 | + |
| 35 | + On = 0x00 |
| 36 | + Previous = 0x01 |
| 37 | + Off = 0x02 |
| 38 | + Inverted = 0x03 |
| 39 | + |
| 40 | + |
| 41 | +class OppleCluster(XiaomiAqaraE1Cluster): |
| 42 | + """Aqara manufacturer-specific cluster for the dimmer switch H2 EU.""" |
| 43 | + |
| 44 | + class AttributeDefs(BaseAttributeDefs): |
| 45 | + """Attribute Definitions.""" |
| 46 | + |
| 47 | + flip_indicator_light = ZCLAttributeDef( |
| 48 | + id=0x00F0, type=types.uint8_t, access="rw", is_manufacturer_specific=True |
| 49 | + ) |
| 50 | + led_indicator = ZCLAttributeDef( |
| 51 | + id=0x0203, type=types.Bool, access="rw", is_manufacturer_specific=True |
| 52 | + ) |
| 53 | + max_brightness = ZCLAttributeDef( |
| 54 | + id=0x0516, type=types.uint8_t, access="rw", is_manufacturer_specific=True |
| 55 | + ) |
| 56 | + min_brightness = ZCLAttributeDef( |
| 57 | + id=0x0515, type=types.uint8_t, access="rw", is_manufacturer_specific=True |
| 58 | + ) |
| 59 | + mode_switch = ZCLAttributeDef( |
| 60 | + id=0x0004, type=types.uint16_t, access="rw", is_manufacturer_specific=True |
| 61 | + ) |
| 62 | + operation_mode = ZCLAttributeDef( |
| 63 | + id=0x0200, type=types.uint8_t, access="rw", is_manufacturer_specific=True |
| 64 | + ) |
| 65 | + phase = ZCLAttributeDef( |
| 66 | + id=0x030A, type=types.uint8_t, access="rw", is_manufacturer_specific=True |
| 67 | + ) |
| 68 | + power_on_state = ZCLAttributeDef( |
| 69 | + id=0x0517, type=types.uint8_t, access="rw", is_manufacturer_specific=True |
| 70 | + ) |
| 71 | + reporting_interval = ZCLAttributeDef( |
| 72 | + id=0x00F6, type=types.uint16_t, access="rw", is_manufacturer_specific=True |
| 73 | + ) |
| 74 | + sensitivity = ZCLAttributeDef( |
| 75 | + id=0x0234, type=types.uint16_t, access="rw", is_manufacturer_specific=True |
| 76 | + ) |
| 77 | + |
| 78 | + |
| 79 | +( |
| 80 | + QuirkBuilder("Aqara", "lumi.switch.agl011") |
| 81 | + .replaces_endpoint(1, device_type=zha.DeviceType.DIMMABLE_LIGHT) |
| 82 | + .adds(DeviceTemperatureCluster) |
| 83 | + .adds(OppleCluster) |
| 84 | + .switch( |
| 85 | + OppleCluster.AttributeDefs.flip_indicator_light.name, |
| 86 | + OppleCluster.cluster_id, |
| 87 | + translation_key="flip_indicator_light", |
| 88 | + fallback_name="Flip indicator light", |
| 89 | + ) |
| 90 | + .switch( |
| 91 | + OppleCluster.AttributeDefs.led_indicator.name, |
| 92 | + OppleCluster.cluster_id, |
| 93 | + translation_key="led_indicator", |
| 94 | + fallback_name="LED indicator", |
| 95 | + ) |
| 96 | + .number( |
| 97 | + OppleCluster.AttributeDefs.max_brightness.name, |
| 98 | + OppleCluster.cluster_id, |
| 99 | + min_value=1, |
| 100 | + max_value=100, |
| 101 | + step=1, |
| 102 | + translation_key="max_brightness", |
| 103 | + fallback_name="Maximum brightness", |
| 104 | + ) |
| 105 | + .number( |
| 106 | + OppleCluster.AttributeDefs.min_brightness.name, |
| 107 | + OppleCluster.cluster_id, |
| 108 | + min_value=0, |
| 109 | + max_value=99, |
| 110 | + step=1, |
| 111 | + translation_key="min_brightness", |
| 112 | + fallback_name="Minimum brightness", |
| 113 | + ) |
| 114 | + .enum( |
| 115 | + OppleCluster.AttributeDefs.mode_switch.name, |
| 116 | + ModeSwitch, |
| 117 | + OppleCluster.cluster_id, |
| 118 | + translation_key="mode_switch", |
| 119 | + fallback_name="Mode switch", |
| 120 | + ) |
| 121 | + .enum( |
| 122 | + OppleCluster.AttributeDefs.operation_mode.name, |
| 123 | + OperationMode, |
| 124 | + OppleCluster.cluster_id, |
| 125 | + translation_key="operation_mode", |
| 126 | + fallback_name="Operation mode", |
| 127 | + ) |
| 128 | + .enum( |
| 129 | + OppleCluster.AttributeDefs.phase.name, |
| 130 | + Phase, |
| 131 | + OppleCluster.cluster_id, |
| 132 | + translation_key="phase", |
| 133 | + fallback_name="Phase", |
| 134 | + ) |
| 135 | + .enum( |
| 136 | + OppleCluster.AttributeDefs.power_on_state.name, |
| 137 | + PowerOnState, |
| 138 | + OppleCluster.cluster_id, |
| 139 | + translation_key="power_on_state", |
| 140 | + fallback_name="Power on state", |
| 141 | + ) |
| 142 | + .number( |
| 143 | + OppleCluster.AttributeDefs.reporting_interval.name, |
| 144 | + OppleCluster.cluster_id, |
| 145 | + min_value=1, |
| 146 | + max_value=3600, |
| 147 | + step=1, |
| 148 | + translation_key="reporting_interval", |
| 149 | + fallback_name="Reporting interval", |
| 150 | + ) |
| 151 | + .number( |
| 152 | + OppleCluster.AttributeDefs.sensitivity.name, |
| 153 | + OppleCluster.cluster_id, |
| 154 | + min_value=1, |
| 155 | + max_value=65535, |
| 156 | + step=1, |
| 157 | + translation_key="sensitivity", |
| 158 | + fallback_name="Sensitivity", |
| 159 | + ) |
| 160 | + .add_to_registry() |
| 161 | +) |
0 commit comments