Skip to content

Prefer device_type over cluster/attribute values for Light#703

Draft
puddly wants to merge 4 commits intozigpy:devfrom
puddly:puddly/stricter-light-device-types
Draft

Prefer device_type over cluster/attribute values for Light#703
puddly wants to merge 4 commits intozigpy:devfrom
puddly:puddly/stricter-light-device-types

Conversation

@puddly
Copy link
Contributor

@puddly puddly commented Mar 9, 2026

This is a test PR to potentially address home-assistant/core#164598 (comment).

I've added the affected devices to our test database and have regenerated diagnostics, showing what devices would be affected if we use the device type more aggressively. I haven't tested the changes yet but this affects very few devices.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.48%. Comparing base (c51efa5) to head (914b77d).

Files with missing lines Patch % Lines
zha/application/platforms/light/__init__.py 63.63% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #703      +/-   ##
==========================================
- Coverage   97.51%   97.48%   -0.04%     
==========================================
  Files          62       62              
  Lines       10946    10954       +8     
==========================================
+ Hits        10674    10678       +4     
- Misses        272      276       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheJulianJES TheJulianJES self-requested a review March 9, 2026 17:42
@puddly
Copy link
Contributor Author

puddly commented Mar 9, 2026

Interestingly, there is not a single device in our testing database that uses a color device type (or a color temperature device type) without also having a color cluster! I would have thought this to not be the case but it looks like manufacturers use the device type pretty strictly compared to clusters themselves.

@puddly puddly force-pushed the puddly/stricter-light-device-types branch from 7a46db7 to 914b77d Compare March 9, 2026 18:20
@puddly
Copy link
Contributor Author

puddly commented Mar 9, 2026

I've added the GLEDOPTO GL-SD-301P to diagnostics as well, from home-assistant/core#164598 (comment). It follows the same pattern: endpoint with a DIMMABLE_LIGHT device type and a bogus Color cluster with no capabilities. We erroneously identify it as a color temperature light. It somehow manages to send attribute reports or something to make ZHA change its color mode.

Copy link
Contributor

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely useful, but I fear we'll break some lights. For a patch release, that's not great.

The main HA issue is that the light gets into a state where color_mode is set to XY (or HS?), even though that is not part of the supported color modes. As far as I can see, this can only ever happen during polling.

The initialization/capabilities set color_mode based on the supported ones, so that should be fine. For an alternative approach that just fixes polling for a patch release, see:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking Z2M and official instructions, the Sengled Z01-A19NAE26 does support color temperature. This patch now changes that to "brightness only". I imagine at least other Sengled lights will be affected as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants