feat: expose per-attribute manual_control as state attributes#1469
Open
jaredjxyz wants to merge 1 commit into
Open
feat: expose per-attribute manual_control as state attributes#1469jaredjxyz wants to merge 1 commit into
jaredjxyz wants to merge 1 commit into
Conversation
Adds two new read-only state attributes on the AdaptiveSwitch entity: - manual_control_brightness: list of light entity_ids whose brightness axis is currently in manual override (i.e. AL is paused for brightness on those lights). - manual_control_color: same, for the color axis. These mirror the existing 'manual_control' attribute (which is a union of both axes) but expose the LightControlAttributes bitfield that AL already tracks internally per-light. Why: the existing 'manual_control' state attribute and the adaptive_lighting.manual_control event are useful, but neither lets a template or dashboard see which axis is paused without subscribing to events. This is especially important with take_over_control_mode: pause_changed, where one axis can be manual while the other still adapts. Now a Lovelace card or template sensor can display brightness/color manual state directly via state_attr(). Test: extends test_manual_control to assert the new attributes reflect the bitfield correctly. No new platform, no breaking changes.
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.
Summary
Adds two new read-only state attributes on the
AdaptiveSwitchentity:manual_control_brightness: list of light entity_ids whose brightness axis is currently in manual override.manual_control_color: same, for the color axis.These mirror the existing `manual_control` attribute (which is a union of both axes) by exposing the `LightControlAttributes` bitfield that AL already tracks internally per-light.
Why
The existing `manual_control` state attribute and the `adaptive_lighting.manual_control` event are useful, but neither lets a template or dashboard see which axis is paused without subscribing to events. This is especially relevant with `take_over_control_mode: pause_changed`, where one axis can be manual while the other still adapts (e.g. user dimmed brightness manually but AL should keep tracking color temp).
After this change:
{# Was just brightness manually changed, with color still adapting? #} {{ 'light.bedroom' in state_attr('switch.adaptive_lighting_bedroom', 'manual_control_brightness') }}Implementation
~12 lines in
custom_components/adaptive_lighting/switch.pyextra_state_attributes. Uses the already-importedLightControlAttributes(no new imports).Tests
Extended
test_manual_controlintests/test_switch.pyto assert that the new attributes reflect the bitfield after a manual brightness change and after a clear viaadaptive_lighting.set_manual_control.Test plan
🤖 Generated with Claude Code