Refactor light entities to use a proper base class #571
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.
To bring
Lightin line with the other entities, I'm refactoringBaseLightto 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 inLight._assume_group_stateto safely be absorbed intoGroupLight.A few things have been renamed, to match the
BaseLightAPI:_supported_color_modesis now_internal_supported_color_modes_external_supported_color_modesis now_supported_color_modesThis has revealed a problem:
stateexposes_external_supported_color_modes, not_supported_color_modes. ZHA doesn't actually use this API (it directly accessesentity.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).