From 54bed8631cdc1dc322caa02c2958b04cb81fbec5 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Sat, 3 Aug 2024 22:37:59 +0200 Subject: [PATCH] Adapt v2 quirks to new zigpy API (#3280) * Use new zigpy quirks v2 API * Bump requirements to zigpy 0.65.2 --- pyproject.toml | 2 +- requirements_test.txt | 2 +- zhaquirks/ikea/fourbtnremote.py | 5 +++-- zhaquirks/ikea/plug.py | 5 +++-- zhaquirks/sonoff/button.py | 5 +++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5dc4d4a895..d0ccc13a86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ readme = "README.md" license = {text = "Apache License Version 2.0"} requires-python = ">=3.12" dependencies = [ - "zigpy>=0.63.5", + "zigpy>=0.65.2", ] [tool.setuptools.packages.find] diff --git a/requirements_test.txt b/requirements_test.txt index fc9b95d033..089ac43b88 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -13,5 +13,5 @@ pytest-sugar pytest-timeout pytest-asyncio pytest>=7.1.3 -zigpy>=0.63.5 +zigpy>=0.65.2 ruff==0.0.261 diff --git a/zhaquirks/ikea/fourbtnremote.py b/zhaquirks/ikea/fourbtnremote.py index 7d486d11d6..17c8f0ba74 100644 --- a/zhaquirks/ikea/fourbtnremote.py +++ b/zhaquirks/ikea/fourbtnremote.py @@ -1,6 +1,6 @@ """Device handler for IKEA of Sweden TRADFRI remote control.""" -from zigpy.quirks.v2 import add_to_registry_v2 +from zigpy.quirks.v2 import QuirkBuilder from zigpy.zcl import ClusterType from zhaquirks.const import ( @@ -29,7 +29,7 @@ from zhaquirks.ikea import IKEA, DoublingPowerConfig2AAACluster, ScenesCluster ( - add_to_registry_v2(IKEA, "Remote Control N2") + QuirkBuilder(IKEA, "Remote Control N2") .replaces(DoublingPowerConfig2AAACluster) # will only double for old firmware .replaces(ScenesCluster, cluster_type=ClusterType.Client) .device_automation_triggers( @@ -106,4 +106,5 @@ }, } ) + .add_to_registry() ) diff --git a/zhaquirks/ikea/plug.py b/zhaquirks/ikea/plug.py index 5a1a9d3da8..860d60d718 100644 --- a/zhaquirks/ikea/plug.py +++ b/zhaquirks/ikea/plug.py @@ -1,13 +1,14 @@ """IKEA plugs quirk.""" -from zigpy.quirks.v2 import add_to_registry_v2 +from zigpy.quirks.v2 import QuirkBuilder from zigpy.zcl.clusters.general import LevelControl from zhaquirks.ikea import IKEA # remove LevelControl for plugs to not show config options in ZHA ( - add_to_registry_v2(IKEA, "TRADFRI control outlet") + QuirkBuilder(IKEA, "TRADFRI control outlet") .also_applies_to(IKEA, "TRETAKT Smart plug") .removes(LevelControl.cluster_id) + .add_to_registry() ) diff --git a/zhaquirks/sonoff/button.py b/zhaquirks/sonoff/button.py index 44fb8eff3e..7eeeef2158 100644 --- a/zhaquirks/sonoff/button.py +++ b/zhaquirks/sonoff/button.py @@ -1,6 +1,6 @@ """Device handler for Sonoff buttons.""" -from zigpy.quirks.v2 import add_to_registry_v2 +from zigpy.quirks.v2 import QuirkBuilder from zhaquirks.const import ( BUTTON, @@ -14,7 +14,7 @@ ) ( - add_to_registry_v2("eWeLink", "WB01") + QuirkBuilder("eWeLink", "WB01") .also_applies_to("eWeLink", "SNZB-01P") .device_automation_triggers( { @@ -23,4 +23,5 @@ (LONG_PRESS, BUTTON): {COMMAND: COMMAND_OFF}, } ) + .add_to_registry() )