Follow-ups from the #884 review: override discard logging, quirk-provided test config, DEFAULT test fixture

Aperta
#887 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
45/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
backend, testing

Direzione di ricerca

Start with aggregate_cluster_configs in zha/zigbee/cluster_config.py around line 119, where attr_name and the cluster are available, and compare the aggregate before and after the merge to log discarded overrides; a prototype commit is referenced in the issue. For the test side, DEFAULT in tests/test_cluster_config.py (line 23) should be replaced by asserting configured[em_attrs.active_power] != RELAXED. The QuirkBuilder change is blocked on a zhaquirks release, so leave that for later. Done means the discard is logged and the test no longer pins ZHA's built-in default.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

code quality

Tracking the inline review comments from #884 that were deliberately deferred rather than addressed in that PR. Filed at TheJulianJES's request (https://github.com/zigpy/zha/pull/884#discussion_r3919402668). All three still apply on dev at 66603431. The one genuine bug from that review is filed separately.

1. Log when an entity's reporting config is discarded by an override

https://github.com/zigpy/zha/pull/884#discussion_r3910746401

Whether an override wins depends on which entities happened to be discovered, and the discard is otherwise invisible: ClusterConfigureReportingEvent carries only the final result, so "why did this device's voltage reporting get slower after an update" has no answer in a normal ZHA debug log and no way to attribute it to a particular entity.

AggregatedAttrConfig.merge does not know the attribute name, so this wants either the name passed in or the log placed at the aggregate_cluster_configs call site (zha/zigbee/cluster_config.py:119), which already has attr_name and the cluster and can compare the aggregate before and after the merge.

TheJulianJES prototyped it as 66044f4ffbfba5ba8cea487f471448922b515ce5 and left it out of #884.

2. Switch the override test to a real QuirkBuilder-provided config

https://github.com/zigpy/zha/pull/884#discussion_r3910699558

test_cluster_config.py patches ElectricalMeasurementRMSCurrent._server_cluster_config to simulate a device-specific override. TheJulianJES's note: this should become a quirks QuirkBuilder actually providing the override config, which needs the zhaquirks bump, which needs a ZHA release containing #884. Patching internals was accepted as the interim.

3. DEFAULT in test_cluster_config.py silently pins ZHA's built-in active_power config

https://github.com/zigpy/zha/pull/884#discussion_r3910746384

DEFAULT = ReportingConfig(min_interval=5, max_interval=900, reportable_change=1) (tests/test_cluster_config.py:23) is not a free-standing fixture — the final assertion configured[em_attrs.active_power] == DEFAULT only holds because it duplicates what ElectricalMeasurementActivePower._server_cluster_config declares for active_power (zha/application/platforms/sensor/init.py:1074-1079). Still identical on dev.

That reportable_change=1 is exactly what the divisor-aware EM reporting follow-up changes, so this assertion will fail on that PR for a reason unrelated to what the test is about. The test's real subject is that the override did not leak to attributes that did not ask for it, which assert configured[em_attrs.active_power] != RELAXED states without pinning the default.

Low priority — it fails loudly and is a one-line fix — but worth knowing before the divisor-aware change lands.

Lingua principale
Python
Stelle
96
Fork
84
Merge medio
2g 4h
PR unite (30g)
30

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di zigpy/zha

Tutte le issue di zigpy/zha

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.