[](https://github.com/hacs/integration)

[](#contributors-)
# π Adaptive Lighting: Enhance Your Home's Atmosphere with Smart, Sun-Synchronized Lighting π

Adaptive Lighting is a custom component for Home Assistant that intelligently adjusts the brightness and color of your lights π‘ based on the sun's position, while still allowing for manual control. Try it out now by finding it in HACS (Home Assistant Community Store) and installing it!
By automatically adapting the settings of your lights throughout the day, Adaptive Lighting helps maintain your natural circadian rhythm π΄, which can lead to improved sleep, mood, and overall well-being. Experience cooler color temperatures at noon, gradually transitioning to warmer colors at sunset and sunrise.
In addition to its regular mode, Adaptive Lighting also offers a "sleep mode" π which sets your lights to minimal brightness and a very warm color, perfect for winding down at night.
[[ToC](#books-table-of-contents)]
## :bulb: Features
Adaptive Lighting provides four switches (using "living_room" as an example component name):
- `switch.adaptive_lighting_living_room`: Turn Adaptive Lighting on or off and view current light settings through its attributes.
- `switch.adaptive_lighting_sleep_mode_living_room`: Activate "sleep mode" π΄ and set custom sleep_brightness and sleep_color_temp.
- `switch.adaptive_lighting_adapt_brightness_living_room`: Enable or disable brightness adaptation π for supported lights.
- `switch.adaptive_lighting_adapt_color_living_room`: Enable or disable color adaptation π for supported lights.
### :control_knobs: Regain Manual Control
Adaptive Lighting is designed to automatically detect when you or another source (e.g., automation) manually changes light settings πΉοΈ.
When this occurs, the affected light is marked as "manually controlled," and Adaptive Lighting will not make further adjustments until the light is turned off and back on or reset using the `adaptive_lighting.set_manual_control` service call.
This feature is available when `take_over_control` is enabled.
Additionally, enabling detect_non_ha_changes allows Adaptive Lighting to detect all state changes, including those made outside of Home Assistant, by comparing the light's state to its previously used settings.
The `adaptive_lighting.manual_control` event is fired when a light is marked as "manually controlled," allowing for integration with automations π€.
## :books: Table of Contents
- [:gear: Configuration](#gear-configuration)
- [:memo: Options](#memo-options)
- [:hammer_and_wrench: Services](#hammer_and_wrench-services)
- [`adaptive_lighting.apply`](#adaptive_lightingapply)
- [`adaptive_lighting.set_manual_control`](#adaptive_lightingset_manual_control)
- [`adaptive_lighting.change_switch_settings`](#adaptive_lightingchange_switch_settings)
- [:robot: Automation examples](#robot-automation-examples)
- [Additional Information](#additional-information)
- [:sos: Troubleshooting](#sos-troubleshooting)
- [:exclamation: Common Problems & Solutions](#exclamation-common-problems--solutions)
- [:bulb: Lights Not Responding or Turning On by Themselves](#bulb-lights-not-responding-or-turning-on-by-themselves)
- [:signal_strength: WiFi Networks](#signal_strength-wifi-networks)
- [:spider_web: Zigbee, Z-Wave, and Other Mesh Networks](#spider_web-zigbee-z-wave-and-other-mesh-networks)
- [:rainbow: Light Colors Not Matching](#rainbow-light-colors-not-matching)
- [:bulb: Bulb-Specific Issues](#bulb-bulb-specific-issues)
- [:bar_chart: Graphs!](#bar_chart-graphs)
- [:sunny: Sun Position](#sunny-sun-position)
- [:thermometer: Color Temperature](#thermometer-color-temperature)
- [:high_brightness: Brightness](#high_brightness-brightness)
- [While using `adapt_until_sleep: true`](#while-using-adapt_until_sleep-true)
- [:busts_in_silhouette: Contributors](#busts_in_silhouette-contributors)
## :gear: Configuration
Adaptive Lighting supports configuration through both YAML and the frontend (**Configuration** -> **Integrations** -> **Adaptive Lighting**, **Adaptive Lighting** -> **Options**), with identical option names in both methods.
```yaml
# Example configuration.yaml entry
adaptive_lighting:
lights:
- light.living_room_lights
```
Transform your home's atmosphere with Adaptive Lighting π , and experience the benefits of intelligent, sun-synchronized lighting today!
### :memo: Options
All of the configuration options are listed below, along with their default values.
The YAML and frontend configuration methods support all of the options listed below.
| Variable name | Description | Default | Type |
|:-------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------|:-------------------------------------|
| `lights` | List of light entity_ids to be controlled (may be empty). π | `[]` | list of `entity_id`s |
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. π | `False` | `bool` |
| `include_config_in_attributes` | Show all options as attributes on the switch in Home Assistant when set to `true`. π | `False` | `bool` |
| `initial_transition` | Duration of the first transition when lights turn from `off` to `on` in seconds. β²οΈ | `1` | `float` 0-6553 |
| `sleep_transition` | Duration of transition when "sleep mode" is toggled in seconds. π΄ | `1` | `float` 0-6553 |
| `transition` | Duration of transition when lights change, in seconds. π | `45` | `float` 0-6553 |
| `transition_until_sleep` | When enabled, Adaptive Lighting will treat sleep settings as the minimum, transitioning to these values after sunset. π | `False` | `bool` |
| `interval` | Frequency to adapt the lights, in seconds. π | `90` | `int > 0` |
| `min_brightness` | Minimum brightness percentage. π‘ | `1` | `int` 1-100 |
| `max_brightness` | Maximum brightness percentage. π‘ | `100` | `int` 1-100 |
| `min_color_temp` | Warmest color temperature in Kelvin. π₯ | `2000` | `int` 1000-10000 |
| `max_color_temp` | Coldest color temperature in Kelvin. βοΈ | `5500` | `int` 1000-10000 |
| `sleep_brightness` | Brightness percentage of lights in sleep mode. π΄ | `1` | `int` 1-100 |
| `sleep_rgb_or_color_temp` | Use either `"rgb_color"` or `"color_temp"` in sleep mode. π | `color_temp` | one of `['color_temp', 'rgb_color']` |
| `sleep_color_temp` | Color temperature in sleep mode (used when `sleep_rgb_or_color_temp` is `color_temp`) in Kelvin. π΄ | `1000` | `int` 1000-10000 |
| `sleep_rgb_color` | RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is "rgb_color"). π | `[255, 56, 0]` | RGB color |
| `sunrise_time` | Set a fixed time (HH:MM:SS) for sunrise. π
| `None` | `str` |
| `max_sunrise_time` | Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier real sunrises. π
| `None` | `str` |
| `sunrise_offset` | Adjust sunrise time with a positive or negative offset in seconds. β° | `0` | `int` |
| `sunset_time` | Set a fixed time (HH:MM:SS) for sunset. π | `None` | `str` |
| `min_sunset_time` | Set the earliest virtual sunset time (HH:MM:SS), allowing for later real sunsets. π | `None` | `str` |
| `sunset_offset` | Adjust sunset time with a positive or negative offset in seconds. β° | `0` | `int` |
| `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). π | `False` | `bool` |
| `take_over_control` | Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! π | `True` | `bool` |
| `detect_non_ha_changes` | Detect non-`light.turn_on` state changes and stop adapting lights. Requires `take_over_control`. π΅οΈ | `False` | `bool` |
| `separate_turn_on_commands` | Use separate `light.turn_on` calls for color and brightness, needed for some light types. π | `False` | `bool` |
| `send_split_delay` | Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. β²οΈ | `0` | `int` 0-10000 |
| `adapt_delay` | Wait time (seconds) between light turn on and Adaptive Lighting applying changes. Might help to avoid flickering. β²οΈ | `0` | `float > 0` |
| `autoreset_control_seconds` | Automatically reset the manual control after a number of seconds. Set to 0 to disable. β²οΈ | `0` | `int` 0-31536000 |
Full example:
```yaml
# Example configuration.yaml entry
adaptive_lighting:
- name: "default"
lights: []
prefer_rgb_color: false
transition: 45
initial_transition: 1
interval: 90
min_brightness: 1
max_brightness: 100
min_color_temp: 2000
max_color_temp: 5500
sleep_brightness: 1
sleep_color_temp: 1000
sunrise_time: "08:00:00" # override the sunrise time
sunrise_offset:
sunset_time:
sunset_offset: 1800 # in seconds or '00:15:00'
take_over_control: true
detect_non_ha_changes: false
only_once: false
```
### :hammer_and_wrench: Services
#### `adaptive_lighting.apply`
`adaptive_lighting.apply` applies Adaptive Lighting settings to lights on demand.
| Service data attribute | Description | Required | Type |
|:-------------------------|:-------------------------------------------------------------------------------------|:-----------|:---------------------|
| `entity_id` | The `entity_id` of the switch with the settings to apply. π | β
| list of `entity_id`s |
| `lights` | A light (or list of lights) to apply the settings to. π‘ | β | list of `entity_id`s |
| `transition` | Duration of transition when lights change, in seconds. π | β | `float` 0-6553 |
| `adapt_brightness` | Whether to adapt the brightness of the light. π | β | bool |
| `adapt_color` | Whether to adapt the color on supporting lights. π | β | bool |
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. π | β | bool |
| `turn_on_lights` | Whether to turn on lights that are currently off. π | β | bool |
#### `adaptive_lighting.set_manual_control`
`adaptive_lighting.set_manual_control` can mark (or unmark) whether a light is "manually controlled", meaning that when a light has `manual_control`, the light is not adapted.
| Service data attribute | Description | Required | Type |
|:-------------------------|:-----------------------------------------------------------------------------------------------|:-----------|:---------------------|
| `entity_id` | The `entity_id` of the switch in which to (un)mark the light as being `manually controlled`. π | β
| list of `entity_id`s |
| `lights` | entity_id(s) of lights, if not specified, all lights in the switch are selected. π‘ | β | list of `entity_id`s |
| `manual_control` | Whether to add ("true") or remove ("false") the light from the "manual_control" list. π | β | bool |
#### `adaptive_lighting.change_switch_settings`
`adaptive_lighting.change_switch_settings` (new in 1.7.0) Change any of the above configuration options of Adaptive Lighting (such as `sunrise_time` or `prefer_rgb_color`) with a service call directly from your script/automation.
| Service data attribute | Required | Description |
| --------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `use_defaults` | β | (default: `current` for current settings) Choose from `factory`, `configuration`, or `current` to reset variables not being set with this service call. `current` leaves them as they are, `configuration` resets to initial startup values, `factory` resets to default values listed in the documentation. |
| **all other keys** (except the ones in the table below β οΈ) | β | See the table below for disallowed keys. |
The following keys are disallowed:
| **DISALLOWED** service data | Description |
| --------------------------- | ----------------------------------------------------------------------------------------------- |
| `entity_id` | You cannot change the switch's `entity_id`, as it has already been registered. |
| `lights` | You may call `adaptive_lighting.apply` with your lights or create a new config instead. |
| `name` | You can rename your switch's display name in Home Assistant's UI. |
| `interval` | The interval is used only once when the config loads. A config change and restart are required. |
## :robot: Automation examples
Reset the
```yaml
- alias: "Adaptive lighting: reset manual_control after 1 hour"
mode: parallel
trigger:
platform: event
event_type: adaptive_lighting.manual_control
variables:
light: "{{ trigger.event.data.entity_id }}"
switch: "{{ trigger.event.data.switch }}"
action:
- delay: "01:00:00"
- condition: template
value_template: "{{ light in state_attr(switch, 'manual_control') }}"
- service: adaptive_lighting.set_manual_control
data:
entity_id: "{{ switch }}"
lights: "{{ light }}"
manual_control: false
```
manual_control status of a light after an hour.Toggle multiple Adaptive Lighting switches to "sleep mode" using an
```yaml
- alias: "Adaptive lighting: toggle 'sleep mode'"
trigger:
- platform: state
entity_id: input_boolean.sleep_mode
- platform: homeassistant
event: start # in case the states aren't properly restored
variables:
sleep_mode: "{{ states('input_boolean.sleep_mode') }}"
action:
service: "switch.turn_{{ sleep_mode }}"
entity_id:
- switch.adaptive_lighting_sleep_mode_living_room
- switch.adaptive_lighting_sleep_mode_bedroom
```
Set your sunrise and sunset time based on your alarm. The below script sets sunset_time exactly 12 hours after the custom sunrise time.
```yaml
iphone_carly_wakeup:
alias: iPhone Carly Wakeup
sequence:
- condition: state
entity_id: input_boolean.carly_iphone_wakeup
state: "off"
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.carly_iphone_wakeup
data:
time: '{{ now().strftime("%H:%M:%S") }}'
- service: input_boolean.turn_on
target:
entity_id: input_boolean.carly_iphone_wakeup
- repeat:
count: >
{{ (states.switch
| map(attribute="entity_id")
| select(">","switch.adaptive_lighting_al_")
| select("<", "switch.adaptive_lighting_al_z")
| join(",")
).split(",") | length }}
sequence:
- service: adaptive_lighting.change_switch_settings
data:
entity_id: switch.adaptive_lighting_al_den_ceilingfan_lights
sunrise_time: '{{ now().strftime("%H:%M:%S") }}'
sunset_time: >
{{ (as_timestamp(now()) + 12*60*60) | timestamp_custom("%H:%M:%S") }}
- service: script.turn_on
target:
entity_id: script.run_wakeup_routine
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.carly_iphone_winddown
- input_boolean.carly_iphone_bedtime
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.wakeup_time
data:
time: '{{ now().strftime("%H:%M:%S") }}'
- service: script.adaptive_lighting_disable_sleep_mode
mode: queued
icon: mdi:weather-sunset
max: 10
```
input_boolean.sleep_mode.