Skip to content

Commit

Permalink
Adapt v2 quirks to new zigpy API (#3280)
Browse files Browse the repository at this point in the history
* Use new zigpy quirks v2 API

* Bump requirements to zigpy 0.65.2
  • Loading branch information
TheJulianJES authored Aug 3, 2024
1 parent e3c115e commit 54bed86
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions zhaquirks/ikea/fourbtnremote.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -106,4 +106,5 @@
},
}
)
.add_to_registry()
)
5 changes: 3 additions & 2 deletions zhaquirks/ikea/plug.py
Original file line number Diff line number Diff line change
@@ -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()
)
5 changes: 3 additions & 2 deletions zhaquirks/sonoff/button.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -14,7 +14,7 @@
)

(
add_to_registry_v2("eWeLink", "WB01")
QuirkBuilder("eWeLink", "WB01")
.also_applies_to("eWeLink", "SNZB-01P")
.device_automation_triggers(
{
Expand All @@ -23,4 +23,5 @@
(LONG_PRESS, BUTTON): {COMMAND: COMMAND_OFF},
}
)
.add_to_registry()
)

0 comments on commit 54bed86

Please sign in to comment.