Quirks v2: no way to disable binding of a cluster (e.g. IasZone)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with zha/zigbee/device.py, zha/zigbee/cluster_config.py, and zha/application/platforms/virtual.py; trace how entity cluster configs are aggregated and applied, including the virtual IasZoneEnrollment bind. Then review QuirkBuilder metadata and the existing test_quirks_v2_prevent_default_entities test. Done means a v2 quirk can suppress the selected cluster bind for virtual and non-virtual entities, with tests confirming the matching configuration is disabled.
索引モデルが issue の本文から書いたものです。
説明
Summary
There is currently no quirks-v2 mechanism to opt a device out of binding a particular cluster (e.g. IasZone). The natural candidate, prevent_default_entity_creation(...), does not achieve this — by design it only suppresses HA entity registration and deliberately leaves the bind/reporting/cluster-config machinery untouched. This request is to add a first-class way for QuirkBuilder to disable a cluster bind (and ideally attribute reporting) for a device.
Found while answering a user question; analysis is against dev @ 3a884dc3.
Why prevent_default_entity_creation can't do this
After #657, binding/reporting/cluster-setup moved onto entities via _server_cluster_config / _client_cluster_config, and IAS Zone enrollment is now driven by the virtual entity IasZoneEnrollment, which declares the bind:
# zha/application/platforms/virtual.py
class IasZoneEnrollment(VirtualEntity):
_server_cluster_config = {
IasZone.cluster_id: ClusterConfig(bind=True, ...),
}
It fails on two independent grounds:
1. The prevent-filter is hardcoded to skip virtual entities. _is_entity_removed_by_quirk returns early for anything on the VIRTUAL platform:
# zha/zigbee/device.py
def _is_entity_removed_by_quirk(self, entity):
if self.quirk_metadata is None:
return False
if entity.PLATFORM == Platform.VIRTUAL:
return False
...
So no prevent_default_entity_creation clause — by cluster_id=0x0500, by unique_id_suffix="_ias_zone_enrollment", or by a function= predicate matching IasZoneEnrollment — can ever match it. (test_quirks_v2_prevent_default_entities asserts exactly this: it filters e.PLATFORM != Platform.VIRTUAL and the virtuals survive.)
2. Even for non-virtual entities, the prevent-filter doesn't stop binding anyway. In _discover_new_entities, the entity is appended to _discovered_entities before the prevent check, and the prevent check only skips on_add() + HA registration:
# zha/zigbee/device.py
for entity in new_entities:
self._discovered_entities.append(entity) # unconditional
if self._is_entity_removed_by_quirk(entity):
continue # only skips on_add + _pending_entities
...
self._pending_entities.append(entity)
Binding then aggregates over _discovered_entities (the full set), not the registered set:
# zha/zigbee/device.py
aggregated = aggregate_cluster_configs(self._discovered_entities)
with agg.bind = agg.bind or config.bind in aggregate_cluster_configs (zha/zigbee/cluster_config.py). So a "prevented" entity's bind=True still takes effect — the filter is purely cosmetic w.r.t. the Zigbee layer.
Note: whether binding should aggregate over
_discovered_entitiesrather than_pending_entitiesis arguably a separate question. It's noted here as the mechanism behind point 2, not as a bug report — for non-virtual entities one could imagine wantingprevent_default_entity_creationto also drop the cluster-config contribution. I've kept it in this one issue since it's the same story; happy to split it out if maintainers prefer.
Proposed enhancement
A way for a quirk to suppress a cluster bind (and ideally reporting), independent of entity creation. Rough sketch — open to whatever shape fits the v2 API best:
- A
QuirkBuildermethod, e.g..prevent_cluster_bind(endpoint_id=..., cluster_id=..., cluster_type=...), recorded in quirk metadata; consulted inaggregate_cluster_configs/configure_cluster_configsso the matching(endpoint, cluster, side)entry is forced tobind=False(and/or reporting suppressed). - This would need to apply to virtual-entity-driven configs too (the IAS Zone case), so it can't reuse the entity-removal path that skips
VIRTUAL.
Use case
Some devices misbehave when the coordinator binds a cluster they nominally expose (duplicate/unwanted reports, enrollment side-effects, devices that should be left to a different controller, etc.). Today a quirk author has no v2-native escape hatch for this; the only recourse is custom cluster subclasses. A declarative opt-out keeps it in the quirk where the device-specific knowledge lives.
cc @TheJulianJES
- 主要言語
- Python
- スター
- 96
- フォーク
- 84
- 平均マージ
- 3日 1時間
- マージ済み PR(30日)
- 13
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
zigpy/zha のほかの issue
-
Analog output numbers and analog input sensors show eleven BACnet engineering units as a different unit対応中かも @zigpy-review-bot が 2 日前に担当しました。 オープンbot: code audit
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
device specific quirks
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
entities
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
quirks
難易度 3/5 半日 初心者へのやさしさ 58/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
pydanty:is-working
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pydantic/pydantic-ai#14472 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
patrickballard/wheelgap#728 ·
-
bug good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
choras-org/simulation-backend#58 ·
メンテナーはふだん 1 日以内に返信
-
backend part-1-modeling testing
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100