From 600fb8f47358c481ad2298134055af78b149a476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Guay-Lambert?= Date: Sat, 26 Oct 2024 12:44:36 -0400 Subject: [PATCH 1/4] Implement contact attribute and skip on/off configuration. --- zhaquirks/philips/soc001.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/zhaquirks/philips/soc001.py b/zhaquirks/philips/soc001.py index 66ef3a1fa6..cbdabff19d 100644 --- a/zhaquirks/philips/soc001.py +++ b/zhaquirks/philips/soc001.py @@ -2,8 +2,25 @@ from zigpy import types from zigpy.quirks import CustomCluster -from zigpy.quirks.v2 import BinarySensorDeviceClass, EntityType, QuirkBuilder +from zigpy.quirks.v2 import ( + BinarySensorDeviceClass, + EntityType, + QuirkBuilder, + ClusterType, +) from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef +from zigpy.zcl.clusters.general import OnOff + + +class PhilipsOnOffCluster(CustomCluster, OnOff): + """Philips OnOff cluster for contact sensor.""" + + """Prevents the creation of the on_off entity.""" + + cluster_id = 6 # 0x0006 + name = "Philips OnOff cluster" + ep_attribute = "philips_onoff_cluster" + SKIP_CONFIGURATION = True class PhilipsContactCluster(CustomCluster): @@ -44,7 +61,21 @@ class AttributeDefs(BaseAttributeDefs): # input_clusters=[0, 1, 3, 64518] # output_clusters=[0, 3, 6, 25]> QuirkBuilder("Signify Netherlands B.V.", "SOC001") + .replaces( + PhilipsOnOffCluster, + cluster_type=ClusterType.Client, + endpoint_id=2, + ) .replaces(PhilipsContactCluster, endpoint_id=2) + .binary_sensor( + "contact", + PhilipsContactCluster.cluster_id, + endpoint_id=2, + device_class=BinarySensorDeviceClass.OPENING, + EntityType=EntityType.STANDARD, + translation_key="contact", + fallback_name="Contact", + ) .binary_sensor( "tamper", PhilipsContactCluster.cluster_id, From 2f31f853b661f381c5eaf67be2712075d14365de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:58:20 +0000 Subject: [PATCH 2/4] Apply pre-commit auto fixes --- zhaquirks/philips/soc001.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zhaquirks/philips/soc001.py b/zhaquirks/philips/soc001.py index cbdabff19d..c17e04ff10 100644 --- a/zhaquirks/philips/soc001.py +++ b/zhaquirks/philips/soc001.py @@ -4,12 +4,12 @@ from zigpy.quirks import CustomCluster from zigpy.quirks.v2 import ( BinarySensorDeviceClass, + ClusterType, EntityType, QuirkBuilder, - ClusterType, ) -from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef from zigpy.zcl.clusters.general import OnOff +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef class PhilipsOnOffCluster(CustomCluster, OnOff): From ec9b691f37c45d6872174a1552106fcf4e1804de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Guay-Lambert?= Date: Sat, 26 Oct 2024 13:11:57 -0400 Subject: [PATCH 3/4] Remove translation_key : https://github.com/zigpy/zha-device-handlers/pull/3461 --- zhaquirks/philips/soc001.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/zhaquirks/philips/soc001.py b/zhaquirks/philips/soc001.py index c17e04ff10..6742c37718 100644 --- a/zhaquirks/philips/soc001.py +++ b/zhaquirks/philips/soc001.py @@ -73,7 +73,6 @@ class AttributeDefs(BaseAttributeDefs): endpoint_id=2, device_class=BinarySensorDeviceClass.OPENING, EntityType=EntityType.STANDARD, - translation_key="contact", fallback_name="Contact", ) .binary_sensor( @@ -82,7 +81,6 @@ class AttributeDefs(BaseAttributeDefs): endpoint_id=2, device_class=BinarySensorDeviceClass.TAMPER, entity_type=EntityType.DIAGNOSTIC, - translation_key="tamper", fallback_name="Tamper", ) .add_to_registry() From 640f9630111a7eb5034476f9abc91a0ed61bd40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Guay-Lambert?= Date: Thu, 14 Nov 2024 13:56:08 -0500 Subject: [PATCH 4/4] Fix entity_type. Co-authored-by: puddly <32534428+puddly@users.noreply.github.com> --- zhaquirks/philips/soc001.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zhaquirks/philips/soc001.py b/zhaquirks/philips/soc001.py index 6742c37718..1a922dad14 100644 --- a/zhaquirks/philips/soc001.py +++ b/zhaquirks/philips/soc001.py @@ -72,7 +72,7 @@ class AttributeDefs(BaseAttributeDefs): PhilipsContactCluster.cluster_id, endpoint_id=2, device_class=BinarySensorDeviceClass.OPENING, - EntityType=EntityType.STANDARD, + entity_type=EntityType.STANDARD, fallback_name="Contact", ) .binary_sensor(