Detect duplicate entities in discovery and log unique ID collisions
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- backend, testing-qa
Direzione di ricerca
Start with default entity discovery and Device._add_pending_entities in zha/zigbee/device.py; trace how input and output clusters produce entities with the same (platform, unique_id) and how the pending path handles them. Add coverage for duplicate discovery and for logging when a distinct entity is dropped, then verify discovery yields one entity and the collision log names both. The issue does not identify the relevant test files, so locate existing discovery and device entity tests first.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Follow-up from zigpy/zha-device-handlers#5410, where duplicate entity detection and unique ID collisions were left for ZHA to fix. ZHA's default discovery can yield the same entity more than once. _add_pending_entities then keeps the first entity for each (platform, unique_id) and drops the rest without logging anything. Discovery should not yield duplicates, and a real collision should be logged.
Problem
- A cluster that is both an input and an output cluster on an endpoint makes default discovery yield two entity objects with the same platform and unique ID. Seen on the NodOn SIN-4-RS-20 cover and the TS0041A switch snapshots.
Device._add_pending_entities(zha/zigbee/device.py, "Ignore entities that already exist") drops a later entity whose key is already taken, with no log._add_entityraises on the same condition, but the pending path never reaches it.- The same silent drop hides quirk mistakes. Two
.adds_entity()calls with the same ZCL class on one endpoint and nounique_id_suffixboth get{ieee}-{endpoint}. An added ZCL entity without a suffix can also collide with a default light, switch or cover, which use the same{ieee}-{endpoint}form. In both cases only the first entity is created, with nothing in the log.
Effect on zha-quirks
QuirkV2Device._replace_entities (zhaquirks/builder/device.py) works around the duplicates: it matches on distinct (PLATFORM, unique_id) and replaces only the first copy. The second copy keeps the original class and still contributes its cluster configuration. If the replacement then fails its support check, ZHA adds that leftover copy, so the original entity comes back, while a single matching entity would produce no entity at all (the open review threads on device.py in zigpy/zha-device-handlers#5410). A replacement class on a different platform keeps the unique ID but not the (platform, unique_id) key, so the leftover copy is added next to the replacement. Once discovery no longer yields duplicates, all of this goes away without a quirks change.
Proposed fix
- Don't yield an entity twice from default discovery, so
QuirkV2Deviceand other consumers see each entity once. - In
_add_pending_entities, log when a different entity is dropped because its(platform, unique_id)is already taken, naming both entities. - Optional, on the quirks side: reject colliding
.adds_entity()calls when the quirk is built. In zigpy/zha-device-handlers#5410 puddly called that nice to have, not needed for a first pass.
Related
is_supported_in_listis the other implicit deduplication:IdentifyButtonuses it to keep one identify button per device. puddly's fork branchpuddly/drop-is-supported-in-list(no PR yet) removesis_supported_in_listand makes the identify button a single device-level entity. It does not touch the input/output cluster duplicates.- zigpy/zha#725 (entity discovery issues) has an
is_supported_in_listitem that this branch would also settle.
- Lingua principale
- Python
- Stelle
- 96
- Fork
- 84
- Merge medio
- 3g 1h
- PR unite (30g)
- 13
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di zigpy/zha
-
Analog output numbers and analog input sensors show eleven BACnet engineering units as a different unitForse già presa @zigpy-review-bot l’ha presa 2 giorni fa. Apertabot: code audit
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
device specific quirks
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
entities
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
quirks
Difficoltà 3/5 Mezza giornata Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
pydanty:is-working
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pydantic/pydantic-ai#14472 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
patrickballard/wheelgap#728 ·
-
bug good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
choras-org/simulation-backend#58 ·
I maintainer di solito rispondono entro 1 giorno
-
backend part-1-modeling testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100