device_config overrides silently ignored for upper case IEEE addresses — fix in ZHA or in HA Core?
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 15/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Tranquilo
- Stack tecnológico
- python, yaml
- Área
- embedded-iot
Línea de trabajo
The mismatch is between create_zha_config in helpers.py, which passes device_overrides through verbatim, and the lookup f"{device.ieee}-{endpoint.id}" in zha/application/discovery.py, where str(EUI64) is lowercase. Before writing code, read the linked branches and wait for a maintainer decision among options A (ZHA lookup), B (HA schema key validator) or A+B. Done means that decision is recorded and a PR is scoped to it.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Splitting this out of #656 because the bug there is confirmed and the open part is a decision: where should it be fixed — here in ZHA, or in the Home Assistant Core ZHA integration? I've prepared both fixes as branches so they can be compared directly. Happy to fold this back into #656 if you'd rather keep it in one place.
The bug (recap of #656)
A device_config platform override in HA's YAML is silently ignored unless the IEEE address is written in lower case:
zha:
device_config:
A4:C1:38:64:XX:XX:XX:XX-1: # ignored
type: switch
a4:c1:38:64:XX:XX:XX:XX-1: # works
type: switch
The cause is that the two sides of the config never agree on a canonical form. HA validates the key as a free-form cv.string and passes it through verbatim into ZHAConfiguration.device_overrides (homeassistant/components/zha/__init__.py, helpers.py::create_zha_config), while ZHA looks it up as f"{device.ieee}-{endpoint.id}" in zha/application/discovery.py — and str(EUI64) is always lower case. A mismatched key is not an error anywhere: the override is just dropped, with no log line and no config error, so the user sees "my override does nothing".
Users hit this because IEEE addresses are commonly displayed in upper case, so a copy-paste produces a key that never matches. It has come up often enough that the docs carry an explicit warning, which was just reworded again because people read it as descriptive rather than as an instruction: home-assistant/home-assistant.io#47347 (and the thread it links, https://community.home-assistant.io/t/zigbee-modifying-the-device-type/349830/20).
Option A — fix it here, in ZHA
Branch: https://github.com/zigpy/zha/compare/dev...zigpy-bot/device-override-ieee-case-insensitive
discover_entities_for_endpoint matches override keys case-insensitively. It is a ~6 line change plus a test, at the only place that reads device_overrides.
- Fixes it for every consumer of the library, not just HA.
- Lookup time rather than config-construction time is deliberate:
device_overridesis a plain dict that HA (and the tests) assign wholesale afterZHAConfigurationis constructed, so normalizing in__post_init__would be bypassed. - Downside: the library can only ever be lenient. It still cannot tell a user why an override did nothing — a typo'd endpoint ID, a wrong-length address or a bogus
type:stays a silent no-op.
Option B — fix it in HA Core, at the YAML schema
A key validator replaces the bare cv.string, canonicalizing <ieee_address>-<endpoint_id> via EUI64.convert() and rejecting anything that is not a valid pair.
- HA owns the user-facing config format, so this is arguably where the canonicalization belongs, and it is the only layer that can turn a broken key into a visible config error instead of a silent no-op.
- It also catches the neighbouring silent failures: a wrong-length address, a non-numeric or out-of-range endpoint ID, and two keys that normalize to the same endpoint (which would otherwise let one entry quietly overwrite the other).
- Downside: HA-only, and it is a (mild) breaking change — a malformed key that was previously accepted-and-ignored now fails validation of the whole
zha:section at startup. Since every newly rejected key was already a no-op, no working configuration can break, but it needs a note on the PR.
The two compose fine if you want both: the schema normalizes before the library's lookup ever sees the key.
Option C — neither
discovery.py carries a TODO: deprecate device platform overrides (the only remaining use case is swapping light / switch for devices with an incorrect device type). If the plan is to remove the feature, doing nothing beyond the docs reword is defensible too.
Which would you prefer?
@TheJulianJES and the other maintainers — I'd like a steer on A, B, C or A+B before opening any PR. My own lean is B (or A+B), because the silent-drop is the actual usability problem and only the schema layer can make it loud, but this is a judgement call about where you want the config contract enforced.
Two related things noticed while writing the branches, worth splitting off if you'd rather not bundle them:
create_zha_configdoesoverride_data["type"], but the schema hasvol.Optional(CONF_TYPE)— adevice_configentry withouttype:raisesKeyErrorduring setup rather than a config error.type:is validated ascv.string, whileDeviceOverridesConfiguration.typeis typedPlatform. A value that isn't a real platform (type: lightt) is accepted and then silently matches nothing.
- Lenguaje dominante
- Python
- Estrellas
- 96
- Forks
- 84
- Merge medio
- 3 d 1 h
- PR fusionados (30 d)
- 13
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de zigpy/zha
-
Analog output numbers and analog input sensors show eleven BACnet engineering units as a different unitPosiblemente ocupada @zigpy-review-bot la tomó hace 2 días. Abiertobot: code audit
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
device specific quirks
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
zigpy/zha#907 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
entities
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
zigpy/zha#855 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
quirks
Dificultad 3/5 Medio día Aptitud para principiantes 58/100
zigpy/zha#1072 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
vllm-project/vllm#69791 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
BCStudentSoftwareDevTeam/cas#481 ·
Los mantenedores suelen responder en 7 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día