|
21 | 21 | import zigpy.zdo.types |
22 | 22 |
|
23 | 23 | import zhaquirks |
24 | | -from zhaquirks import const |
25 | 24 | import zhaquirks.bosch.motion |
26 | 25 | import zhaquirks.centralite.cl_3310S |
27 | 26 | from zhaquirks.const import ( |
@@ -469,102 +468,6 @@ def test_quirk_loading_error(tmp_path: Path, caplog) -> None: |
469 | 468 | assert "cannot import name 'foobarbaz7' from 'os'" in caplog.text |
470 | 469 |
|
471 | 470 |
|
472 | | -def test_custom_quirk_loading( |
473 | | - zigpy_device_from_quirk: CustomDevice, tmp_path: Path |
474 | | -) -> None: |
475 | | - """Make sure custom quirks take priority over regular quirks.""" |
476 | | - |
477 | | - device = zigpy_device_from_quirk( |
478 | | - zhaquirks.bosch.motion.ISWZPR1WP13, apply_quirk=False |
479 | | - ) |
480 | | - assert type(device) is zigpy.device.Device |
481 | | - |
482 | | - # Make sure our target quirk will load after we re-setup zhaquirks |
483 | | - zhaquirks.setup() |
484 | | - assert type(zq.get_device(device)) is zhaquirks.bosch.motion.ISWZPR1WP13 |
485 | | - |
486 | | - custom_quirks = tmp_path / "custom_zha_quirks" |
487 | | - custom_quirks.mkdir() |
488 | | - |
489 | | - # Make our own custom quirk |
490 | | - (custom_quirks / "__init__.py").touch() |
491 | | - |
492 | | - (custom_quirks / "bosch").mkdir() |
493 | | - (custom_quirks / "bosch/__init__.py").touch() |
494 | | - (custom_quirks / "bosch/custom_quirk.py").write_text( |
495 | | - ''' |
496 | | -"""Device handler for Bosch motion sensors.""" |
497 | | -from zigpy.profiles import zha |
498 | | -from zigpy.quirks import CustomDevice |
499 | | -from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl |
500 | | -from zigpy.zcl.clusters.homeautomation import Diagnostic |
501 | | -from zigpy.zcl.clusters.measurement import TemperatureMeasurement |
502 | | -from zigpy.zcl.clusters.security import IasZone |
503 | | -
|
504 | | -from zhaquirks import PowerConfigurationCluster |
505 | | -
|
506 | | -from zhaquirks.bosch import BOSCH |
507 | | -from zhaquirks.const import ( |
508 | | - DEVICE_TYPE, |
509 | | - ENDPOINTS, |
510 | | - INPUT_CLUSTERS, |
511 | | - MODELS_INFO, |
512 | | - OUTPUT_CLUSTERS, |
513 | | - PROFILE_ID, |
514 | | -) |
515 | | -
|
516 | | -class TestReplacementISWZPR1WP13(CustomDevice): |
517 | | - """Custom device representing Bosch motion sensors.""" |
518 | | -
|
519 | | - signature = { |
520 | | - # <SimpleDescriptor endpoint=1 profile=260 device_type=1026 |
521 | | - # device_version=0 |
522 | | - # input_clusters=[0, 1, 3, 1026, 1280, 32, 2821] |
523 | | - # output_clusters=[25]> |
524 | | - MODELS_INFO: [(BOSCH, "ISW-ZPR1-WP13")], |
525 | | - ENDPOINTS: { |
526 | | - 5: { |
527 | | - PROFILE_ID: zha.PROFILE_ID, |
528 | | - DEVICE_TYPE: zha.DeviceType.IAS_ZONE, |
529 | | - INPUT_CLUSTERS: [ |
530 | | - Basic.cluster_id, |
531 | | - PowerConfigurationCluster.cluster_id, |
532 | | - Identify.cluster_id, |
533 | | - PollControl.cluster_id, |
534 | | - TemperatureMeasurement.cluster_id, |
535 | | - IasZone.cluster_id, |
536 | | - Diagnostic.cluster_id, |
537 | | - ], |
538 | | - OUTPUT_CLUSTERS: [Ota.cluster_id], |
539 | | - } |
540 | | - }, |
541 | | - } |
542 | | -
|
543 | | - replacement = { |
544 | | - ENDPOINTS: { |
545 | | - 5: { |
546 | | - INPUT_CLUSTERS: [ |
547 | | - Basic.cluster_id, |
548 | | - PowerConfigurationCluster.cluster_id, |
549 | | - Identify.cluster_id, |
550 | | - PollControl.cluster_id, |
551 | | - TemperatureMeasurement.cluster_id, |
552 | | - IasZone.cluster_id, |
553 | | - Diagnostic.cluster_id, |
554 | | - ], |
555 | | - OUTPUT_CLUSTERS: [Ota.cluster_id], |
556 | | - } |
557 | | - } |
558 | | - } |
559 | | -''' |
560 | | - ) |
561 | | - |
562 | | - zhaquirks.setup(custom_quirks_path=str(custom_quirks)) |
563 | | - |
564 | | - assert not isinstance(zq.get_device(device), zhaquirks.bosch.motion.ISWZPR1WP13) |
565 | | - assert type(zq.get_device(device)).__name__ == "TestReplacementISWZPR1WP13" |
566 | | - |
567 | | - |
568 | 471 | def test_zigpy_custom_cluster_pollution() -> None: |
569 | 472 | """Ensure all quirks subclass `CustomCluster`.""" |
570 | 473 | non_zigpy_clusters = { |
|
0 commit comments