Add BEGA light color temperature channel#721
Merged
TheJulianJES merged 8 commits intozigpy:devfrom Mar 25, 2026
Merged
Conversation
4 tasks
e7b6ecd to
1bf2f61
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #721 +/- ##
=======================================
Coverage 97.62% 97.62%
=======================================
Files 62 62
Lines 10764 10789 +25
=======================================
+ Hits 10508 10533 +25
Misses 256 256 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds ZHA support for BEGA lights that can switch between two fixed white color temperature channels by exposing the functionality as a dedicated config select entity (instead of trying to fit it into the standard light color temperature UI).
Changes:
- Extend
LevelControlClusterHandlerinitialization reads to include BEGA “switchable white” attributes when the BEGA exposed feature flag is present. - Add a new
selectentity (BegaColorTemperatureChannelSelect) backed by theswitchable_whiteattribute, and suppress entity creation when both temperature attributes report0xFFFF. - Add test coverage plus a new BEGA device JSON fixture to validate entity creation, updates, writes, and the unsupported (
0xFFFF) case.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
zha/zigbee/cluster_handlers/general.py |
Reads BEGA-specific LevelControl attributes at initialization when the BEGA feature is exposed. |
zha/application/platforms/select.py |
Introduces BEGA color temperature channel enum + select entity and support gating via 0xFFFF temps. |
tests/test_select.py |
Adds tests for the new BEGA select entity (normal + unsupported cases). |
tests/data/devices/bega-gantenbrink-leuchten-kg-smart-dimmable-light.json |
Adds a BEGA device fixture with the relevant attributes/features for integration-style tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Some BEGA lights have a driver that allows you to switch between two color temperatures. This is something that should only be changed sometimes, e.g. after setup. This PR adds support for that.
For lights where this feature is not supported, the attributes are still available to be read but
switchable_color_temperature_1andswitchable_color_temperature_2shall have the value0xFFFF. This is why we need a ZHA entity to implement this, instead of a basic quirks v2 entity.Note 1
As only two color temperatures are supported (as separate channels) and this isn't meant to be adjusted all the time, it does not make sense to try and hack this into the light entity. The HA frontend would still show a smooth gradient for the color temperature and it's not possible to properly display either just (e.g.) 3000K or 4000K there, without allowing any values in between that.
This is why a separate config select entity is added.
Note 2:
ZHA currently assumes that
Bool.falseis warm-white andBool.trueis cool-white. We intentionally do not use whatever color temperatures are available on theswitchable_color_temperature_Xattributes, as we'd need to use that as state for the select entity. This could then differ between lights.If it turns out the rule mentioned above doesn't apply to all devices, we could either rename the options to "Channel 1" and "Chanel 2", or have ZHA automatically swap what the select entity options do when chosen. For now, I'd not this, until it becomes clear that we actually need this (or not).
Note 3:
It would also be good to know if the
switchable_whiteattribute returnsUNSUPPORTED_ATTRIBUTEon dimmable-only lights, or if0xFFFFfor the other two attributes is the only indication this feature is not supported.Most other entities just check the attribute they base state on.
Additional information
Requires (and see for more information):