From 11e4dd0764e84c7b61be97960bd8d93d03f964b3 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Wed, 27 Dec 2023 15:15:45 -0500 Subject: [PATCH] Bump ZHA quirks to 109 and add associated configuration entities (#106492) --- .../cluster_handlers/manufacturerspecific.py | 11 ++++ homeassistant/components/zha/manifest.json | 2 +- homeassistant/components/zha/select.py | 62 +++++++++++++++++++ homeassistant/components/zha/strings.json | 9 +++ requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 6 files changed, 85 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/zha/core/cluster_handlers/manufacturerspecific.py b/homeassistant/components/zha/core/cluster_handlers/manufacturerspecific.py index 556eb907605..57f1e2ee304 100644 --- a/homeassistant/components/zha/core/cluster_handlers/manufacturerspecific.py +++ b/homeassistant/components/zha/core/cluster_handlers/manufacturerspecific.py @@ -149,6 +149,17 @@ class OppleRemote(ClusterHandler): "buzzer": True, "linkage_alarm": True, } + elif self.cluster.endpoint.model == "lumi.magnet.ac01": + self.ZCL_INIT_ATTRS = { + "detection_distance": True, + } + elif self.cluster.endpoint.model == "lumi.switch.acn047": + self.ZCL_INIT_ATTRS = { + "switch_mode": True, + "switch_type": True, + "startup_on_off": True, + "decoupled_mode": True, + } async def async_initialize_cluster_handler_specific(self, from_cache: bool) -> None: """Initialize cluster handler specific.""" diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index a2965e782f4..6a14a3064a6 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -24,7 +24,7 @@ "bellows==0.37.4", "pyserial==3.5", "pyserial-asyncio==0.6", - "zha-quirks==0.0.108", + "zha-quirks==0.0.109", "zigpy-deconz==0.22.3", "zigpy==0.60.2", "zigpy-xbee==0.20.1", diff --git a/homeassistant/components/zha/select.py b/homeassistant/components/zha/select.py index 2ff8b7d36b9..1c13779209d 100644 --- a/homeassistant/components/zha/select.py +++ b/homeassistant/components/zha/select.py @@ -7,6 +7,8 @@ import logging from typing import TYPE_CHECKING, Any, Self from zhaquirks.quirk_ids import TUYA_PLUG_MANUFACTURER, TUYA_PLUG_ONOFF +from zhaquirks.xiaomi.aqara.magnet_ac01 import OppleCluster as MagnetAC01OppleCluster +from zhaquirks.xiaomi.aqara.switch_acn047 import OppleCluster as T2RelayOppleCluster from zigpy import types from zigpy.zcl.clusters.general import OnOff from zigpy.zcl.clusters.security import IasWd @@ -408,6 +410,66 @@ class AqaraApproachDistance(ZCLEnumSelectEntity): _attr_translation_key: str = "approach_distance" +@CONFIG_DIAGNOSTIC_MATCH( + cluster_handler_names="opple_cluster", models={"lumi.magnet.ac01"} +) +class AqaraMagnetAC01DetectionDistance(ZCLEnumSelectEntity): + """Representation of a ZHA detection distance configuration entity.""" + + _unique_id_suffix = "detection_distance" + _attribute_name = "detection_distance" + _enum = MagnetAC01OppleCluster.DetectionDistance + _attr_translation_key: str = "detection_distance" + + +@CONFIG_DIAGNOSTIC_MATCH( + cluster_handler_names="opple_cluster", models={"lumi.switch.acn047"} +) +class AqaraT2RelaySwitchMode(ZCLEnumSelectEntity): + """Representation of a ZHA switch mode configuration entity.""" + + _unique_id_suffix = "switch_mode" + _attribute_name = "switch_mode" + _enum = T2RelayOppleCluster.SwitchMode + _attr_translation_key: str = "switch_mode" + + +@CONFIG_DIAGNOSTIC_MATCH( + cluster_handler_names="opple_cluster", models={"lumi.switch.acn047"} +) +class AqaraT2RelaySwitchType(ZCLEnumSelectEntity): + """Representation of a ZHA switch type configuration entity.""" + + _unique_id_suffix = "switch_type" + _attribute_name = "switch_type" + _enum = T2RelayOppleCluster.SwitchType + _attr_translation_key: str = "switch_type" + + +@CONFIG_DIAGNOSTIC_MATCH( + cluster_handler_names="opple_cluster", models={"lumi.switch.acn047"} +) +class AqaraT2RelayStartupOnOff(ZCLEnumSelectEntity): + """Representation of a ZHA startup on off configuration entity.""" + + _unique_id_suffix = "startup_on_off" + _attribute_name = "startup_on_off" + _enum = T2RelayOppleCluster.StartupOnOff + _attr_translation_key: str = "start_up_on_off" + + +@CONFIG_DIAGNOSTIC_MATCH( + cluster_handler_names="opple_cluster", models={"lumi.switch.acn047"} +) +class AqaraT2RelayDecoupledMode(ZCLEnumSelectEntity): + """Representation of a ZHA switch decoupled mode configuration entity.""" + + _unique_id_suffix = "decoupled_mode" + _attribute_name = "decoupled_mode" + _enum = T2RelayOppleCluster.DecoupledMode + _attr_translation_key: str = "decoupled_mode" + + class AqaraE1ReverseDirection(types.enum8): """Aqara curtain reversal.""" diff --git a/homeassistant/components/zha/strings.json b/homeassistant/components/zha/strings.json index 18bb3ae4f82..00d24fbc82e 100644 --- a/homeassistant/components/zha/strings.json +++ b/homeassistant/components/zha/strings.json @@ -780,6 +780,15 @@ }, "preset": { "name": "Preset" + }, + "detection_distance": { + "name": "Detection distance" + }, + "switch_mode": { + "name": "Switch mode" + }, + "decoupled_mode": { + "name": "Decoupled mode" } }, "sensor": { diff --git a/requirements_all.txt b/requirements_all.txt index 31a7b55ceea..ef621c9ce94 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2866,7 +2866,7 @@ zeroconf==0.131.0 zeversolar==0.3.1 # homeassistant.components.zha -zha-quirks==0.0.108 +zha-quirks==0.0.109 # homeassistant.components.zhong_hong zhong-hong-hvac==1.0.9 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 32ff3d43dcf..3e3256385fc 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2168,7 +2168,7 @@ zeroconf==0.131.0 zeversolar==0.3.1 # homeassistant.components.zha -zha-quirks==0.0.108 +zha-quirks==0.0.109 # homeassistant.components.zha zigpy-deconz==0.22.3