|
| 1 | +"""Telink TLSR825x based devices with custom firmware. |
| 2 | +
|
| 3 | +see https://github.com/pvvx/ZigbeeTLc |
| 4 | +""" |
| 5 | + |
| 6 | +from zigpy.quirks.v2 import QuirkBuilder |
| 7 | +from zigpy.quirks.v2.homeassistant import UnitOfTemperature, UnitOfTime |
| 8 | +import zigpy.types as t |
| 9 | +from zigpy.zcl import ClusterType |
| 10 | +from zigpy.zcl.clusters.hvac import UserInterface |
| 11 | +from zigpy.zcl.foundation import ZCLAttributeDef |
| 12 | + |
| 13 | +from zhaquirks import CustomCluster |
| 14 | + |
| 15 | + |
| 16 | +class Display(t.enum8): |
| 17 | + """Turn off the display.""" |
| 18 | + |
| 19 | + Off = 0x01 |
| 20 | + On = 0x00 |
| 21 | + |
| 22 | + |
| 23 | +class CustomUserInterfaceCluster(CustomCluster, UserInterface): |
| 24 | + """Custom User Interface Cluster with smiley control.""" |
| 25 | + |
| 26 | + class AttributeDefs(UserInterface.AttributeDefs): |
| 27 | + """Attribute Definitions.""" |
| 28 | + |
| 29 | + # display. 0 - display is off, 1 - display is on |
| 30 | + display = ZCLAttributeDef( |
| 31 | + id=0x0106, |
| 32 | + type=Display, |
| 33 | + access="rw", |
| 34 | + is_manufacturer_specific=True, |
| 35 | + ) |
| 36 | + |
| 37 | + # comfort temperature min: A value in 0.01ºC to set minimum comfort temperature for happy face |
| 38 | + comfort_temperature_min = ZCLAttributeDef( |
| 39 | + id=0x0102, |
| 40 | + type=t.int16s, |
| 41 | + access="rw", |
| 42 | + is_manufacturer_specific=True, |
| 43 | + ) |
| 44 | + |
| 45 | + # comfort temperature max: A value in 0.01ºC to set maximum comfort temperature for happy face |
| 46 | + comfort_temperature_max = ZCLAttributeDef( |
| 47 | + id=0x0103, |
| 48 | + type=t.int16s, |
| 49 | + access="rw", |
| 50 | + is_manufacturer_specific=True, |
| 51 | + ) |
| 52 | + |
| 53 | + # comfort humidity min: A value in 0.01%RH to set minimum comfort humidity for happy face |
| 54 | + comfort_humidity_min = ZCLAttributeDef( |
| 55 | + id=0x0104, |
| 56 | + type=t.uint16_t, |
| 57 | + access="rw", |
| 58 | + is_manufacturer_specific=True, |
| 59 | + ) |
| 60 | + |
| 61 | + # comfort humidity max: A value in 0.01%RH to set maximum comfort humidity for happy face |
| 62 | + comfort_humidity_max = ZCLAttributeDef( |
| 63 | + id=0x0105, |
| 64 | + type=t.uint16_t, |
| 65 | + access="rw", |
| 66 | + is_manufacturer_specific=True, |
| 67 | + ) |
| 68 | + |
| 69 | + # A value in 0.01ºC offset to fix up incorrect values from sensor |
| 70 | + temperature_offset = ZCLAttributeDef( |
| 71 | + id=0x0100, |
| 72 | + type=t.int16s, |
| 73 | + access="rw", |
| 74 | + is_manufacturer_specific=True, |
| 75 | + ) |
| 76 | + |
| 77 | + # A value in 0.01%RH offset to fix up incorrect values from sensor |
| 78 | + humidity_offset = ZCLAttributeDef( |
| 79 | + id=0x0101, |
| 80 | + type=t.int16s, |
| 81 | + access="rw", |
| 82 | + is_manufacturer_specific=True, |
| 83 | + ) |
| 84 | + # Measurement interval, step 1 second, range: 3..255 seconds. Default 10 seconds. |
| 85 | + measurement_interval = ZCLAttributeDef( |
| 86 | + id=0x0107, |
| 87 | + type=t.uint8_t, |
| 88 | + access="rw", |
| 89 | + is_manufacturer_specific=True, |
| 90 | + ) |
| 91 | + |
| 92 | + |
| 93 | +( |
| 94 | + QuirkBuilder("MiaoMiaoCe", "MHO-C401N-z") |
| 95 | + .applies_to("MiaMiaoCe", "MHO-C401N-z") # typo until v. 1.2.2 |
| 96 | + .applies_to("MiaoMiaoCe", "MHO-C401-z") |
| 97 | + .applies_to("MiaoMiaoCe", "MHO-C122-z") |
| 98 | + .applies_to("MiaMiaoCe", "MHO-C122-z") # typo until v. 1.2.2 |
| 99 | + .applies_to("Xiaomi", "LYWSD03MMC-z") |
| 100 | + .applies_to("Tuya", "TS0201-z") |
| 101 | + .applies_to("Tuya", "TH03Z-z") |
| 102 | + .applies_to("Tuya", "ZTH01-z") |
| 103 | + .applies_to("Tuya", "ZTH02-z") |
| 104 | + .applies_to("Tuya", "LKTMZL02-z") |
| 105 | + .applies_to("Sonoff", "TH03-z") |
| 106 | + .applies_to("Qingping", "CGDK2-z") |
| 107 | + .removes(CustomUserInterfaceCluster.cluster_id, cluster_type=ClusterType.Client) |
| 108 | + .adds(CustomUserInterfaceCluster) |
| 109 | + .number( |
| 110 | + CustomUserInterfaceCluster.AttributeDefs.temperature_offset.name, |
| 111 | + CustomUserInterfaceCluster.cluster_id, |
| 112 | + min_value=-327.67, |
| 113 | + max_value=327.67, |
| 114 | + step=0.01, |
| 115 | + unit=UnitOfTemperature.CELSIUS, |
| 116 | + translation_key="temperature_offset", |
| 117 | + fallback_name="Temperature offset", |
| 118 | + multiplier=0.01, |
| 119 | + mode="box", |
| 120 | + ) |
| 121 | + .number( |
| 122 | + CustomUserInterfaceCluster.AttributeDefs.humidity_offset.name, |
| 123 | + CustomUserInterfaceCluster.cluster_id, |
| 124 | + min_value=-327.67, |
| 125 | + max_value=327.67, |
| 126 | + step=0.01, |
| 127 | + # unit=PERCENTAGE, |
| 128 | + translation_key="humidity_offset", |
| 129 | + fallback_name="Humidity offset", |
| 130 | + multiplier=0.01, |
| 131 | + mode="box", |
| 132 | + ) |
| 133 | + .number( |
| 134 | + CustomUserInterfaceCluster.AttributeDefs.comfort_temperature_min.name, |
| 135 | + CustomUserInterfaceCluster.cluster_id, |
| 136 | + min_value=-327.67, |
| 137 | + max_value=327.67, |
| 138 | + step=0.01, |
| 139 | + unit=UnitOfTemperature.CELSIUS, |
| 140 | + translation_key="comfort_temperature_min", |
| 141 | + fallback_name="Comfort temperature min", |
| 142 | + multiplier=0.01, |
| 143 | + mode="box", |
| 144 | + ) |
| 145 | + .number( |
| 146 | + CustomUserInterfaceCluster.AttributeDefs.comfort_temperature_max.name, |
| 147 | + CustomUserInterfaceCluster.cluster_id, |
| 148 | + min_value=-327.67, |
| 149 | + max_value=327.67, |
| 150 | + step=0.01, |
| 151 | + unit=UnitOfTemperature.CELSIUS, |
| 152 | + translation_key="comfort_temperature_max", |
| 153 | + fallback_name="Comfort temperature max", |
| 154 | + multiplier=0.01, |
| 155 | + mode="box", |
| 156 | + ) |
| 157 | + .number( |
| 158 | + CustomUserInterfaceCluster.AttributeDefs.comfort_humidity_min.name, |
| 159 | + CustomUserInterfaceCluster.cluster_id, |
| 160 | + min_value=0, |
| 161 | + max_value=99, |
| 162 | + step=1, |
| 163 | + # unit=PERCENTAGE, |
| 164 | + translation_key="comfort_humidity_min", |
| 165 | + fallback_name="Comfort humidity min", |
| 166 | + multiplier=0.01, |
| 167 | + mode="box", |
| 168 | + ) |
| 169 | + .number( |
| 170 | + CustomUserInterfaceCluster.AttributeDefs.comfort_humidity_max.name, |
| 171 | + CustomUserInterfaceCluster.cluster_id, |
| 172 | + min_value=0, |
| 173 | + max_value=99, |
| 174 | + step=1, |
| 175 | + # unit=PERCENTAGE, |
| 176 | + translation_key="comfort_humidity_max", |
| 177 | + fallback_name="Comfort humidity max", |
| 178 | + multiplier=0.01, |
| 179 | + mode="box", |
| 180 | + ) |
| 181 | + .number( |
| 182 | + CustomUserInterfaceCluster.AttributeDefs.measurement_interval.name, |
| 183 | + CustomUserInterfaceCluster.cluster_id, |
| 184 | + min_value=3, |
| 185 | + max_value=255, |
| 186 | + unit=UnitOfTime.SECONDS, |
| 187 | + translation_key="measurement_interval", |
| 188 | + fallback_name="Measurement interval", |
| 189 | + mode="box", |
| 190 | + ) |
| 191 | + .switch( |
| 192 | + CustomUserInterfaceCluster.AttributeDefs.display.name, |
| 193 | + CustomUserInterfaceCluster.cluster_id, |
| 194 | + off_value=1, |
| 195 | + on_value=0, |
| 196 | + translation_key="display_enabled", |
| 197 | + fallback_name="Display enabled", |
| 198 | + ) |
| 199 | + .switch( |
| 200 | + CustomUserInterfaceCluster.AttributeDefs.schedule_programming_visibility.name, |
| 201 | + CustomUserInterfaceCluster.cluster_id, |
| 202 | + translation_key="show_smiley", |
| 203 | + fallback_name="Show smiley", |
| 204 | + ) |
| 205 | + .add_to_registry() |
| 206 | +) |
0 commit comments