Skip to content

feat: expose per-attribute manual_control as state attributes#1469

Open
jaredjxyz wants to merge 1 commit into
basnijholt:mainfrom
jaredjxyz:expose-manual-control-attrs
Open

feat: expose per-attribute manual_control as state attributes#1469
jaredjxyz wants to merge 1 commit into
basnijholt:mainfrom
jaredjxyz:expose-manual-control-attrs

Conversation

@jaredjxyz
Copy link
Copy Markdown

@jaredjxyz jaredjxyz commented Apr 25, 2026

Summary

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.
  • 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.py extra_state_attributes. Uses the already-imported LightControlAttributes (no new imports).

Tests

Extended test_manual_control in tests/test_switch.py to assert that the new attributes reflect the bitfield after a manual brightness change and after a clear via adaptive_lighting.set_manual_control.

Test plan

  • `test_manual_control` updated and asserts both new attributes
  • No new platform; no breaking changes
  • Existing `manual_control` attribute behavior unchanged

🤖 Generated with Claude Code

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.
@jaredjxyz jaredjxyz requested a review from basnijholt as a code owner April 25, 2026 19:57
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