Skip to content

Conversation

@puddly
Copy link
Contributor

@puddly puddly commented Nov 7, 2025

To bring Light in line with the other entities, I'm refactoring BaseLight to actually be a base entity type. The current base class was more of a base implementation and expected cluster handlers to exist, in addition to making other assumptions. I've split things off into:

  • BaseLight: implements the external light entity API, nothing more.
  • BaseClusterHandlerLight: implements the gargantuan ZCL-ish API to control lights, based on the presence of various cluster handlers and so on.

I took this opportunity to get rid of kwargs.get(... and have replaced this pattern with typed kwargs. This allowed the logic in Light._assume_group_state to safely be absorbed into GroupLight.

A few things have been renamed, to match the BaseLight API:

  1. _supported_color_modes is now _internal_supported_color_modes
  2. _external_supported_color_modes is now _supported_color_modes

This has revealed a problem: state exposes _external_supported_color_modes, not _supported_color_modes. ZHA doesn't actually use this API (it directly accesses entity.supported_color_modes) but it's still a strange behavior. I think we should change this and regenerate diagnostics.


The purpose of this change is to allow light entities to be created for coordinators that have LEDs. These light entities are not going to be communicating with devices via Zigbee, using any sort of ZCL functionality, or even really attached to a device object in any way (like counter entities).

@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 93.70079% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.01%. Comparing base (54975cb) to head (26454b6).

Files with missing lines Patch % Lines
zha/application/platforms/light/__init__.py 93.54% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #571      +/-   ##
==========================================
- Coverage   97.02%   97.01%   -0.02%     
==========================================
  Files          63       63              
  Lines       10535    10537       +2     
==========================================
  Hits        10222    10222              
- Misses        313      315       +2     

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

@puddly puddly force-pushed the puddly/refactor-base-light branch from 58ea5bd to 26454b6 Compare November 8, 2025 19:01
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.

1 participant