mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Allow match quirk_class of custom quirks to ZHA (#93268)
* Allow matching custom quirks when self.quirk_classes might not contain the full class path but only the module and the class. * Add test for matching custom quirk classes.
This commit is contained in:
parent
0f4c71f993
commit
deafdc3005
@ -244,7 +244,10 @@ class MatchRule:
|
|||||||
if callable(self.quirk_classes):
|
if callable(self.quirk_classes):
|
||||||
matches.append(self.quirk_classes(quirk_class))
|
matches.append(self.quirk_classes(quirk_class))
|
||||||
else:
|
else:
|
||||||
matches.append(quirk_class in self.quirk_classes)
|
matches.append(
|
||||||
|
quirk_class.split(".")[-2:]
|
||||||
|
in [x.split(".")[-2:] for x in self.quirk_classes]
|
||||||
|
)
|
||||||
|
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ if typing.TYPE_CHECKING:
|
|||||||
|
|
||||||
MANUFACTURER = "mock manufacturer"
|
MANUFACTURER = "mock manufacturer"
|
||||||
MODEL = "mock model"
|
MODEL = "mock model"
|
||||||
QUIRK_CLASS = "mock.class"
|
QUIRK_CLASS = "mock.test.quirk.class"
|
||||||
|
QUIRK_CLASS_SHORT = "quirk.class"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -209,6 +210,12 @@ def cluster_handlers(cluster_handler):
|
|||||||
),
|
),
|
||||||
False,
|
False,
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
registries.MatchRule(
|
||||||
|
cluster_handler_names="on_off", quirk_classes=QUIRK_CLASS_SHORT
|
||||||
|
),
|
||||||
|
True,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_registry_matching(rule, matched, cluster_handlers) -> None:
|
def test_registry_matching(rule, matched, cluster_handlers) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user