Device override creates the generic entity instead of the vendor-specific one (Light instead of HueLight, ForceOnLight, MinTransitionLight)

Open Beginner friendly
#1,110 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@zigpy-review-bot is already working on this.

Since Nov 30, 2026.

  • #1111 by @zigpy-review-bot — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, testing

Research direction

Start with discover_entities_for_endpoint in zha/application/discovery.py and compare its override selection with test_device_override_picks_highest_priority in tests/test_discover.py. Run the two failing tests named in the issue against the device fixtures. Done when override discovery keeps only the highest priority match for the override platform, including the vendor specific light cases.

Written by the indexing model from the issue text.

Description

bot: code audit
Problem

Severity: low (the audit's estimate)

A device override (device_config with type: light, switch, cover, …) makes ZHA create the override platform's generic entity instead of that platform's vendor-specific entity for the device. With a light override, a Philips/Signify light gets Light instead of HueLight, a Jasco, Quotra-Vision, eWeLight or eWeLink light gets Light instead of ForceOnLight, and a Sengled device gets Light instead of MinTransitionLight. The same happens with a cover override on a Keen Home vent (Shade instead of KeenVent), and the same selection runs in every feature group that ranks several entities of one platform (for example the fan and climate entities of the thermostat/fan group). The vendor-specific behaviour is then silently lost. For example, ForceOnLight is the one that sends an explicit On for lights that don't turn on with a level command, and MinTransitionLight is the one that sends a 0.1 s transition instead of 0 to lights that ignore a 0 transition.

The cause is in discover_entities_for_endpoint in zha/application/discovery.py. With an override, when a feature group has matches of the override platform, the matches of each of its priority levels are first narrowed to that platform, and the highest level is picked. A second block right after collects the override platform's matches from every level again and replaces the selection with all of them. So both the base entity (priority 0) and the vendor entity (priority 1) are created, under the same unique ID. Device._add_pending_entities keeps the first one, which is the base entity, and drops the vendor entity. test_device_override_picks_highest_priority already states the intent, that an override selects only the highest-priority match rather than collecting all priority levels, but it only covers a switch override, where there is a single switch priority level.

Code at the audited commit: https://github.com/zigpy/zha/blob/4d8e640c877c998e66b74ad2059c9e1ed1b07510/zha/application/discovery.py#L327-L339

Evidence

Two tests on the device fixtures in tests/data/devices/ fail at dev: a Philips LCT014 light with a light override yields two light entities (Light and HueLight), and a Sengled E1C-NB7 plug (discovered as a switch) overridden to a light gets Light instead of MinTransitionLight.

Failing test output at dev
E       assert 2 == 1
E        +  where 2 = len([<zha.application.platforms.light.Light object at 0x7869f64dbd90>, <zha.application.platforms.light.HueLight object at 0x7869f64dbb10>])
E       AssertionError: assert <class 'zha.application.platforms.light.Light'> is MinTransitionLight
E        +  where <class 'zha.application.platforms.light.Light'> = type(<zha.application.platforms.light.Light object at 0x7869f5729bd0>)
FAILED tests/test_discover.py::test_device_override_keeps_priority_within_platform
FAILED tests/test_discover.py::test_device_override_to_light_uses_vendor_light
2 failed, 5 passed, 1160 deselected in 1.19s
Proposed fix

Remove the second override block. In a feature group with matches of the override platform, the first block already leaves only that platform's matches in each priority level, so taking the highest level selects the override platform's highest-priority entity, which is what test_device_override_picks_highest_priority expects. With a single priority level of the override platform (a switch override, or a light override on a device that only the generic Light matches), and in feature groups without a match of the override platform, the result is the same as today.

Dominant language
Python
Stars
96
Forks
84
Avg merge
2d 4h
Merged PRs (30d)
30

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zigpy/zha

All issues in zigpy/zha

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.