2525MANUFACTURER = "mock manufacturer"
2626MODEL = "mock model"
2727QUIRK_CLASS = "mock.test.quirk.class"
28- QUIRK_ID = "quirk_id "
28+ EXPOSED_FEATURE = "EXPOSED_FEATURE_ID "
2929
3030
3131@pytest .fixture
@@ -97,14 +97,19 @@ def cluster_handlers(cluster_handler):
9797 MatchRule (models = "no match" , aux_cluster_handlers = "aux_cluster_handler" ),
9898 False ,
9999 ),
100- (MatchRule (quirk_ids = QUIRK_ID ), True ),
101- (MatchRule (quirk_ids = "no match" ), False ),
100+ (MatchRule (exposed_features = EXPOSED_FEATURE ), True ),
101+ (MatchRule (exposed_features = "no match" ), False ),
102102 (
103- MatchRule (quirk_ids = QUIRK_ID , aux_cluster_handlers = "aux_cluster_handler" ),
103+ MatchRule (
104+ exposed_features = EXPOSED_FEATURE ,
105+ aux_cluster_handlers = "aux_cluster_handler" ,
106+ ),
104107 True ,
105108 ),
106109 (
107- MatchRule (quirk_ids = "no match" , aux_cluster_handlers = "aux_cluster_handler" ),
110+ MatchRule (
111+ exposed_features = "no match" , aux_cluster_handlers = "aux_cluster_handler"
112+ ),
108113 False ,
109114 ),
110115 # match everything
@@ -114,7 +119,7 @@ def cluster_handlers(cluster_handler):
114119 cluster_handler_names = {"on_off" , "level" },
115120 manufacturers = MANUFACTURER ,
116121 models = MODEL ,
117- quirk_ids = QUIRK_ID ,
122+ exposed_features = EXPOSED_FEATURE ,
118123 ),
119124 True ,
120125 ),
@@ -167,39 +172,41 @@ def cluster_handlers(cluster_handler):
167172 (
168173 MatchRule (
169174 cluster_handler_names = "on_off" ,
170- quirk_ids = {"random quirk" , QUIRK_ID },
175+ exposed_features = {"random quirk" , EXPOSED_FEATURE },
171176 ),
172177 True ,
173178 ),
174179 (
175180 MatchRule (
176181 cluster_handler_names = "on_off" ,
177- quirk_ids = {"random quirk" , "another quirk" },
182+ exposed_features = {"random quirk" , "another quirk" },
178183 ),
179184 False ,
180185 ),
181186 (
182187 MatchRule (
183- cluster_handler_names = "on_off" , quirk_ids = lambda x : x == QUIRK_ID
188+ cluster_handler_names = "on_off" ,
189+ exposed_features = lambda x : x == EXPOSED_FEATURE ,
184190 ),
185191 True ,
186192 ),
187193 (
188194 MatchRule (
189- cluster_handler_names = "on_off" , quirk_ids = lambda x : x != QUIRK_ID
195+ cluster_handler_names = "on_off" ,
196+ exposed_features = lambda x : x != EXPOSED_FEATURE ,
190197 ),
191198 False ,
192199 ),
193200 (
194- MatchRule (cluster_handler_names = "on_off" , quirk_ids = QUIRK_ID ),
201+ MatchRule (cluster_handler_names = "on_off" , exposed_features = EXPOSED_FEATURE ),
195202 True ,
196203 ),
197204 ],
198205)
199206def test_registry_matching (rule , matched , cluster_handlers ) -> None :
200207 """Test strict rule matching."""
201208 assert (
202- rule .strict_matched (MANUFACTURER , MODEL , cluster_handlers , {QUIRK_ID })
209+ rule .strict_matched (MANUFACTURER , MODEL , cluster_handlers , {EXPOSED_FEATURE })
203210 is matched
204211 )
205212
@@ -288,16 +295,16 @@ def test_registry_matching(rule, matched, cluster_handlers) -> None:
288295 (MatchRule (manufacturers = MANUFACTURER ), True ),
289296 (MatchRule (models = MODEL ), True ),
290297 (MatchRule (models = "no match" ), False ),
291- (MatchRule (quirk_ids = QUIRK_ID ), True ),
292- (MatchRule (quirk_ids = "no match" ), False ),
298+ (MatchRule (exposed_features = EXPOSED_FEATURE ), True ),
299+ (MatchRule (exposed_features = "no match" ), False ),
293300 # match everything
294301 (
295302 MatchRule (
296303 generic_ids = {"cluster_handler_0x0006" , "cluster_handler_0x0008" },
297304 cluster_handler_names = {"on_off" , "level" },
298305 manufacturers = MANUFACTURER ,
299306 models = MODEL ,
300- quirk_ids = QUIRK_ID ,
307+ exposed_features = EXPOSED_FEATURE ,
301308 ),
302309 True ,
303310 ),
@@ -306,7 +313,8 @@ def test_registry_matching(rule, matched, cluster_handlers) -> None:
306313def test_registry_loose_matching (rule , matched , cluster_handlers ) -> None :
307314 """Test loose rule matching."""
308315 assert (
309- rule .loose_matched (MANUFACTURER , MODEL , cluster_handlers , {QUIRK_ID }) is matched
316+ rule .loose_matched (MANUFACTURER , MODEL , cluster_handlers , {EXPOSED_FEATURE })
317+ is matched
310318 )
311319
312320
@@ -370,12 +378,12 @@ def entity_registry():
370378
371379
372380@pytest .mark .parametrize (
373- ("manufacturer" , "model" , "quirk_id " , "match_name" ),
381+ ("manufacturer" , "model" , "exposes_features " , "match_name" ),
374382 [
375383 ("random manufacturer" , "random model" , "random.class" , "OnOff" ),
376384 ("random manufacturer" , MODEL , "random.class" , "OnOffModel" ),
377385 (MANUFACTURER , "random model" , "random.class" , "OnOffManufacturer" ),
378- ("random manufacturer" , "random model" , QUIRK_ID , "OnOffQuirk" ),
386+ ("random manufacturer" , "random model" , EXPOSED_FEATURE , "OnOffQuirk" ),
379387 (MANUFACTURER , MODEL , "random.class" , "OnOffModelManufacturer" ),
380388 (MANUFACTURER , "some model" , "random.class" , "OnOffMultimodel" ),
381389 ],
@@ -385,7 +393,7 @@ def test_weighted_match(
385393 entity_registry : PlatformEntityRegistry ,
386394 manufacturer ,
387395 model ,
388- quirk_id ,
396+ exposes_features ,
389397 match_name ,
390398) -> None :
391399 """Test weightedd match."""
@@ -426,7 +434,7 @@ class OnOffModelManufacturer: # pylint: disable=unused-variable
426434 """OnOff model and manufacturer cluster handler."""
427435
428436 @entity_registry .strict_match (
429- s .component , cluster_handler_names = "on_off" , quirk_ids = QUIRK_ID
437+ s .component , cluster_handler_names = "on_off" , exposed_features = EXPOSED_FEATURE
430438 )
431439 class OnOffQuirk : # pylint: disable=unused-variable
432440 """OnOff quirk cluster handler."""
@@ -435,7 +443,7 @@ class OnOffQuirk: # pylint: disable=unused-variable
435443 ch_level = cluster_handler ("level" , 8 )
436444
437445 match , claimed = entity_registry .get_entity (
438- s .component , manufacturer , model , [ch_on_off , ch_level ], {quirk_id }
446+ s .component , manufacturer , model , [ch_on_off , ch_level ], {exposes_features }
439447 )
440448
441449 assert match .__name__ == match_name
@@ -463,7 +471,7 @@ class SmartEnergySensor2:
463471 "manufacturer" ,
464472 "model" ,
465473 cluster_handlers = [ch_se , ch_illuminati ],
466- quirk_ids = {"quirk_id " },
474+ exposes_features = {"exposed_feature_id " },
467475 )
468476
469477 assert s .binary_sensor in match
@@ -493,7 +501,7 @@ class SmartEnergySensor3:
493501 "manufacturer" ,
494502 "model" ,
495503 cluster_handlers = {ch_se , ch_illuminati },
496- quirk_ids = {"quirk_id " },
504+ exposes_features = {"exposed_feature_id " },
497505 )
498506
499507 assert s .binary_sensor in match
@@ -541,21 +549,23 @@ def quirk_class_validator(value):
541549 quirk_class_validator (v )
542550 return
543551
544- if value not in all_quirk_ids :
545- raise ValueError (f"Quirk ID '{ value } ' does not exist." )
552+ if value not in all_exposed_features :
553+ raise ValueError (f"Exposed feature '{ value } ' does not exist." )
546554
547555 # get all quirk ID from zigpy quirks registry
548- all_quirk_ids : set [str ] = set ()
556+ all_exposed_features : set [str ] = set ()
549557 for manufacturer in zigpy_quirks ._DEVICE_REGISTRY .registry_v1 .values ():
550558 for model_quirk_list in manufacturer .values ():
551559 for quirk in model_quirk_list :
552560 qid : set [str ] | str = getattr (quirk , ATTR_QUIRK_ID , set ())
553- device_quirk_ids : set [str ] = {qid } if isinstance (qid , str ) else set (qid )
554- all_quirk_ids .update (device_quirk_ids )
561+ device_exposed_features : set [str ] = (
562+ {qid } if isinstance (qid , str ) else set (qid )
563+ )
564+ all_exposed_features .update (device_exposed_features )
555565
556566 # validate all quirk IDs used in component match rules
557567 for rule , _ in iter_all_rules ():
558- quirk_class_validator (rule .quirk_ids )
568+ quirk_class_validator (rule .exposed_features )
559569
560570
561571def test_entity_names () -> None :
0 commit comments