Skip to content

Add BEGA light color temperature channel#721

Merged
TheJulianJES merged 8 commits intozigpy:devfrom
TheJulianJES:tjj/bega_light
Mar 25, 2026
Merged

Add BEGA light color temperature channel#721
TheJulianJES merged 8 commits intozigpy:devfrom
TheJulianJES:tjj/bega_light

Conversation

@TheJulianJES
Copy link
Copy Markdown
Contributor

@TheJulianJES TheJulianJES commented Mar 24, 2026

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_1 and switchable_color_temperature_2 shall have the value 0xFFFF. 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.false is warm-white and Bool.true is cool-white. We intentionally do not use whatever color temperatures are available on the switchable_color_temperature_X attributes, 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_white attribute returns UNSUPPORTED_ATTRIBUTE on dimmable-only lights, or if 0xFFFF for 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):

@TheJulianJES TheJulianJES marked this pull request as ready for review March 25, 2026 03:37
Copilot AI review requested due to automatic review settings March 25, 2026 03:37
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.62%. Comparing base (5a353cf) to head (1bf2f61).
⚠️ Report is 2 commits behind head on dev.

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.
📢 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 LevelControlClusterHandler initialization reads to include BEGA “switchable white” attributes when the BEGA exposed feature flag is present.
  • Add a new select entity (BegaColorTemperatureChannelSelect) backed by the switchable_white attribute, and suppress entity creation when both temperature attributes report 0xFFFF.
  • 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.

@TheJulianJES TheJulianJES merged commit f721c73 into zigpy:dev Mar 25, 2026
13 checks passed
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