Adaptive Lighting user configuration
Adaptive Lighting lets a Home Assistant user create named lighting profiles and apply time-based light settings to selected lights. Each profile becomes a group of Home Assistant switch entities that the user can configure, enable, pause, and control through services.
Configuration entry lifecycle
An Adaptive Lighting instance is a named configuration entry that owns one set of lights and its runtime controls. Home Assistant can create the entry from the UI or import it from YAML, then load the switch platform that exposes the instance.
flowchart LR
A[Create in UI or YAML] --> B[Named Adaptive Lighting instance]
B --> C[Main adaptation switch]
B --> D[Sleep Mode switch]
B --> E[Adapt Color switch]
B --> F[Adapt Brightness switch]
C --> G[Time-based light updates]
D --> G
E --> G
F --> G
UI creation and duplication
The UI asks for a unique instance name. When other instances already exist, the same flow also offers a duplication choice. Duplication copies the source instance's option values into the new entry, but the new instance still needs its own unique name. custom_components/…/config_flow.py.
The UI creation flow stores the name as the entry title and uses the name as the instance identity. A repeated name is rejected rather than creating a second instance with an ambiguous identity. custom_components/…/strings.json.
References: custom_components/…/config_flow.py• L31-84 custom_components/…/strings.json• L3-21
YAML import
YAML provides a way to declare one or more named instances in configuration.yaml. The integration validates the list and imports each declaration into Home Assistant's configuration-entry system, so the runtime controls are the same as for a UI-created instance. custom_components/…/__init__.py.
Each YAML instance must have a unique name. Its options are managed by the YAML declaration rather than by the interactive options form. To change such an instance, edit the YAML configuration and reload the relevant Home Assistant configuration. custom_components/…/config_flow.py.
References: custom_components/…/__init__.py• L22-59 custom_components/…/config_flow.py• L86-101 custom_components/…/config_flow.py• L142-152
Configuration changes
The options flow is the main UI path for changing a UI-created instance. It presents the same option names used by YAML and checks that selected light entities still exist before accepting changes. Saving the options reloads the instance so the new values take effect. custom_components/…/config_flow.py.
Configuration option groups
The options define the profile's target lights and its time-based behavior. They also set how the profile responds to user actions and how it handles sleep settings, transitions, manual control, and light-service interception. The UI keeps the main light and timing choices visible and places the less common controls in a collapsed advanced section.
The detailed option contract is documented in Configuration flow and options. That page is the child reference for defaults, accepted values, validation, and the UI presentation of each option.
References: custom_components/…/config_flow.py• L129-202 custom_components/…/const.py• L344-355 custom_components/…/const.py• L363-459
Runtime setting changes
Automations can change most settings without replacing the instance by calling adaptive_lighting.change_switch_settings. The service targets one Adaptive Lighting switch and can use the current values, the saved configuration values, or the factory values for fields that the call does not provide. The instance applies the new settings at once when its main switch is on. custom_components/…/switch.py.
This service does not change the instance name, target-light list, or adaptation interval. It can change the light-group handling policy, but explicit service light targets remain explicit targets. custom_components/…/switch.py.
References: custom_components/…/switch.py• L377-413 custom_components/…/switch.py• L942-1014 custom_components/…/const.py• L528-538 custom_components/…/services.yaml• L65-270
Instance controls
Each instance exposes one main switch and three related switches. The main switch controls whether the profile is active. The related switches select sleep behavior and whether the active profile may change color or brightness.
Main adaptation switch
Turning the main switch on starts the instance's listeners and its repeated time-based updates. It also applies the current profile to lights that are on. Turning it off stops those updates and clears the instance's tracked light-control state. Home Assistant restores the prior main-switch state when the entity is added again. custom_components/…/switch.py.
Sleep and attribute switches
Sleep Mode selects the profile's sleep values. Changing it immediately reapplies the profile with the sleep transition. Adapt Color and Adapt Brightness act as independent gates, so a user can pause one attribute while the other continues to follow the profile. New instances start with Sleep Mode off and both attribute switches on. custom_components/…/switch.py.
References: custom_components/…/switch.py• L518-555 custom_components/…/switch.py• L1063-1078 custom_components/…/switch.py• L1267-1295 custom_components/…/switch.py• L1712-1733 custom_components/…/switch.py• L1758-1830
Light control and manual ownership
An active instance responds to light turn-on events and can intercept supported light.turn_on calls when interception is enabled. This lets the instance apply its current color and brightness as part of a light turn-on instead of waiting for the next scheduled update. Multi-light interception can split a call across instances when all targeted instances allow it. custom_components/…/switch.py.
When another Home Assistant source changes a light that is already on, the instance can mark the changed attributes as manually controlled. The instance then pauses those attributes until the light or instance resets that state. Users can also set or clear this state directly with adaptive_lighting.set_manual_control. custom_components/…/switch.py.
Light groups can either be expanded to their member lights or kept as group targets. This choice affects normal profile tracking and manual-control records. Explicit member targets in a service call remain individual targets. custom_components/…/switch.py.
The Switches and service controls page explains the service fields, target rules, and event controls in detail. Use the instance switch as entity_id when a service call must identify a specific profile.
References: custom_components/…/switch.py• L1984-2088 custom_components/…/switch.py• L2083-2237 custom_components/…/switch.py• L2396-2453 custom_components/…/switch.py• L2533-2577 custom_components/…/const.py• L276-299
User control flow
The user-facing control paths converge on the same instance state. Configuration changes replace the active settings, entity switches change which parts of those settings are used, and services can apply or pause those settings for selected lights.
sequenceDiagram
participant U as User or automation
participant H as Home Assistant
participant I as Adaptive Lighting instance
participant L as Managed lights
U->>H: Change options or call a service
H->>I: Update profile or control state
I->>I: Recalculate active settings
I->>L: Apply color and/or brightness
L-->>H: Report light state
H-->>I: Report state and manual changes
The apply service uses the current instance settings for a chosen set of lights. By default it does not turn off lights, but its turn_on_lights option can include lights that are off. The set_manual_control service can address all lights in the selected instance or a chosen subset, and it supports full or attribute-specific manual control. custom_components/…/const.py and custom_components/…/services.yaml.
References: custom_components/…/switch.py• L302-485 custom_components/…/const.py• L513-549 custom_components/…/services.yaml• L2-64
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the option definitions, their validation, and the options-flow schema aligned. A field that is valid in YAML but absent from the UI can leave a UI-created entry with different behavior.
- Keep the service schemas and service descriptions aligned with the handlers. The service UI is generated from the declared fields while runtime validation comes from the switch platform.
- Preserve the unique-name rule across UI creation and YAML import. The name is also the identity used to group the instance's entities.
- When changing the set of runtime-changeable settings, update the
change_switch_settingsallow-list without making immutable identity fields changeable by accident. - When changing interception or manual-control rules, check both single-light and multi-light targeting. A call can span lights in different instances.
- When changing light-group handling, keep profile tracking, service targeting, and interception behavior aligned. Group expansion must not turn an explicit member target into a group target.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A new instance uses a name that already exists | The UI flow aborts instead of creating the entry. | Use a unique instance name. |
| A configured light no longer exists | The options flow reports a missing-entity error and does not accept the configuration until the target is corrected. | Remove the stale entity or restore it in Home Assistant. |
| A light-targeted service call matches more than one instance | The target instance cannot be selected safely. The service requires an explicit switch entity in this case. | Pass the intended Adaptive Lighting switch as entity_id. |
detect_non_ha_changes or adapt_only_on_bare_turn_on is enabled while take_over_control is disabled | The instance forces take-over control on so the dependent behavior can operate. | Treat take_over_control as required for those options. |
multi_light_intercept is enabled while intercept is disabled | Multi-light interception is disabled. | Enable intercept first, or leave multi-light interception off. |
| A multi-light intercepted call targets instances that do not all allow multi-light interception | Adaptive Lighting skips interception for the full call and passes the original light command through. | Enable multi_light_intercept on every involved instance, or use separate calls. |
apply targets lights that are off without turn_on_lights | Those lights are not changed by the apply action. | Set turn_on_lights: true when the action should also turn lights on. |
Key files
| File | Why to read it |
|---|---|
| custom_components/…/config_flow.py | Defines UI creation, duplication, YAML import behavior, and option changes. |
| custom_components/…/const.py | Defines the user-facing option names, defaults, validation, and service schemas. |
| custom_components/…/switch.py | Connects each configuration entry to its main switch, related switches, runtime changes, light-group behavior, and user services. |
| custom_components/…/__init__.py | Shows how YAML declarations enter Home Assistant and how configuration entries are loaded or unloaded. |
| custom_components/…/strings.json | Defines the names, descriptions, and validation errors shown in the Home Assistant UI. |
| custom_components/…/services.yaml | Describes the fields exposed to users and automations for apply, manual control, and runtime setting changes. |