mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-16 16:54:04 +02:00
Merge remote-tracking branch 'origin/main' into fix/external-turn-on-policy
# Conflicts: # README.md # custom_components/adaptive_lighting/const.py # custom_components/adaptive_lighting/strings.json # custom_components/adaptive_lighting/translations/en.json # docs/configuration.md
This commit is contained in:
commit
a9c5790a9c
77 changed files with 6927 additions and 1973 deletions
|
|
@ -20,6 +20,20 @@ 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 🤖.
|
||||
|
||||
The Adaptive Lighting switch exposes these read-only attributes for its lights:
|
||||
|
||||
- `manual_control`: lights with any attribute marked as manually controlled.
|
||||
- `manual_control_brightness`: lights with brightness marked as manually controlled.
|
||||
- `manual_control_color`: lights with color marked as manually controlled.
|
||||
|
||||
These lists report manual-control flags. Actual adaptation also depends on `take_over_control_mode` and the brightness/color adaptation switches. For example, under the default `pause_all` mode, manually changing only brightness leaves `manual_control_color` empty while pausing both brightness and color adaptation. Under `pause_changed`, color can continue adapting.
|
||||
|
||||
The attributes are absent when the Adaptive Lighting switch is off. Use a fallback when checking them in templates:
|
||||
|
||||
```jinja
|
||||
{{ 'light.bedroom' in (state_attr('switch.adaptive_lighting_bedroom', 'manual_control_brightness') or []) }}
|
||||
```
|
||||
|
||||
> ⚠️ **_Caution: Some lights might falsely indicate an 'on' state, which could result in lights turning on unexpectedly. Disable `detect_non_ha_changes` if you encounter such issues._**
|
||||
|
||||
<!-- OUTPUT:END -->
|
||||
|
|
@ -100,11 +114,13 @@ adaptive_lighting:
|
|||
|
||||
### adapt_only_on_ha_turn_on
|
||||
|
||||
When enabled, a light that turns on from `off` is only adapted if the turn-on came from a Home Assistant `light.turn_on` call. Lights turned on by an external source — a physical wall switch or a hub/manufacturer scene (such as a Lutron keypad or Pico scene) — are marked as manually controlled and left at whatever brightness/color that source set, instead of being immediately overridden by Adaptive Lighting.
|
||||
When enabled, a light that turns on from `off` is only adapted if the state-change context exactly matches the most recent Home Assistant `light.turn_on` context recorded for that light. An unmatched turn-on is marked as manually controlled and left at its reported brightness and color.
|
||||
|
||||
This is the option to reach for when turning a light on with its local switch (or a native Lutron/Caséta scene) makes Adaptive Lighting override your brightness a moment later, forcing you to set it twice.
|
||||
|
||||
Its advantage over simply disabling `detect_non_ha_changes` is that the two behaviors are decoupled: you can keep `detect_non_ha_changes: true` to catch manual dimming of lights that are *already on*, while still leaving *externally turned-on* lights untouched.
|
||||
Its advantage over simply disabling `detect_non_ha_changes` is that the two behaviors are decoupled: you can keep `detect_non_ha_changes: true` to catch manual dimming of lights that are *already on*, while leaving unmatched turn-ons untouched.
|
||||
|
||||
Adaptive Lighting cannot identify every physical versus Home Assistant source. Some integrations replace or omit the service context when they publish device state. In that case, even a Home Assistant turn-on does not match and this option treats it as external.
|
||||
|
||||
```yaml
|
||||
adaptive_lighting:
|
||||
|
|
@ -113,7 +129,7 @@ adaptive_lighting:
|
|||
- light.living_room
|
||||
take_over_control: true
|
||||
detect_non_ha_changes: true # still catch manual changes to already-on lights
|
||||
adapt_only_on_ha_turn_on: true # but don't override external off→on turn-ons
|
||||
adapt_only_on_ha_turn_on: true # leave unmatched off→on events unchanged
|
||||
```
|
||||
|
||||
## Checking Manual Control Status
|
||||
|
|
|
|||
|
|
@ -12,29 +12,27 @@ Real-world automation examples showing how to integrate Adaptive Lighting with y
|
|||
<!-- CODE:END -->
|
||||
<!-- OUTPUT:START -->
|
||||
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
|
||||
Replace every entity ID below with the IDs from your Home Assistant instance. Fresh Adaptive Lighting profiles use child IDs such as `switch.adaptive_lighting_living_room_sleep_mode`; profiles created before the device-based entity change may retain older IDs.
|
||||
|
||||
Blocks that begin with `- alias` are entries for `automations.yaml`. Blocks with a top-level `script:` or `adaptive_lighting:` key are complete `configuration.yaml` examples. If your configuration uses `script: !include scripts.yaml`, omit that outer key and place its contents in `scripts.yaml`.
|
||||
|
||||
`change_switch_settings` updates a profile while its main switch is off, but lights are adapted only while that switch is on. It preserves manual-control flags, so manually controlled lights remain paused.
|
||||
|
||||
<details markdown="1">
|
||||
<summary>Reset the <code>manual_control</code> status of a light after an hour.</summary>
|
||||
<summary>Automatically reset manual control after one hour.</summary>
|
||||
|
||||
Use the built-in timeout so every new manual change renews a single timer for that light:
|
||||
|
||||
```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
|
||||
adaptive_lighting:
|
||||
- name: "Living Room"
|
||||
lights:
|
||||
- light.living_room
|
||||
autoreset_control_seconds: 3600
|
||||
```
|
||||
|
||||
This is a top-level `configuration.yaml` example. The timer clears manual control and immediately readapts a light when both it and the Adaptive Lighting switch are on.
|
||||
|
||||
</details>
|
||||
|
||||
<details markdown="1">
|
||||
|
|
@ -46,69 +44,269 @@ Real-world automation examples showing how to integrate Adaptive Lighting with y
|
|||
- platform: state
|
||||
entity_id: input_boolean.sleep_mode
|
||||
- platform: homeassistant
|
||||
event: start # in case the states aren't properly restored
|
||||
event: start # apply the helper's restored state
|
||||
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
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: "{{ sleep_mode in ['on', 'off'] }}"
|
||||
actions:
|
||||
- action: "switch.turn_{{ sleep_mode }}"
|
||||
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
|
||||
- switch.adaptive_lighting_living_room_sleep_mode
|
||||
- switch.adaptive_lighting_bedroom_sleep_mode
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details markdown="1">
|
||||
<summary>Set sunrise and sunset from an alarm.</summary>
|
||||
|
||||
Call this script from your alarm automation. It sets one Adaptive Lighting profile's sunrise to the current time and its sunset to 12 hours later on the local clock.
|
||||
|
||||
```yaml
|
||||
script:
|
||||
set_adaptive_lighting_alarm_times:
|
||||
alias: "Adaptive lighting: set times from alarm"
|
||||
variables:
|
||||
alarm_time: '{{ now().strftime("%H:%M:%S") }}'
|
||||
sequence:
|
||||
- action: adaptive_lighting.change_switch_settings
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_alarm_lights
|
||||
sunrise_time: "{{ alarm_time }}"
|
||||
sunset_time: >
|
||||
{{ (strptime(alarm_time, "%H:%M:%S") + timedelta(hours=12))
|
||||
.strftime("%H:%M:%S") }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details markdown="1">
|
||||
<summary>Use a Schedule helper as a step-based custom lighting profile.</summary>
|
||||
|
||||
Create a [Schedule helper](https://www.home-assistant.io/integrations/schedule/) named `Adaptive Lighting Profile`. Add time blocks with Additional data like this:
|
||||
|
||||
```yaml
|
||||
brightness_pct: 20
|
||||
color_temp_kelvin: 2500
|
||||
```
|
||||
|
||||
Use different values for each block. The automation below applies the active block whenever the schedule state or its attributes change. Setting both brightness limits and both color temperature limits to the same value keeps each block at its setpoint. Outside a block, the configured Adaptive Lighting settings are restored.
|
||||
|
||||
```yaml
|
||||
- alias: "Adaptive lighting: apply scheduled profile"
|
||||
triggers:
|
||||
- trigger: state
|
||||
entity_id: schedule.adaptive_lighting_profile
|
||||
- trigger: homeassistant
|
||||
event: start
|
||||
actions:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: schedule.adaptive_lighting_profile
|
||||
state: "on"
|
||||
sequence:
|
||||
- action: adaptive_lighting.change_switch_settings
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_living_room
|
||||
min_brightness: >
|
||||
{{ state_attr('schedule.adaptive_lighting_profile', 'brightness_pct') | int(1) }}
|
||||
max_brightness: >
|
||||
{{ state_attr('schedule.adaptive_lighting_profile', 'brightness_pct') | int(1) }}
|
||||
min_color_temp: >
|
||||
{{ state_attr('schedule.adaptive_lighting_profile', 'color_temp_kelvin') | int(2000) }}
|
||||
max_color_temp: >
|
||||
{{ state_attr('schedule.adaptive_lighting_profile', 'color_temp_kelvin') | int(2000) }}
|
||||
default:
|
||||
- action: adaptive_lighting.change_switch_settings
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_living_room
|
||||
use_defaults: configuration
|
||||
mode: restart
|
||||
```
|
||||
|
||||
This creates step changes at block boundaries. It does not interpolate between schedule points. Runtime settings also reset when Home Assistant restarts, so the startup trigger reapplies the active block. The default branch restores every configured setting; restore only the four fields explicitly if other automations also change runtime settings.
|
||||
|
||||
</details>
|
||||
|
||||
<details markdown="1">
|
||||
<summary>Reduce daytime brightness when an illuminance sensor detects strong daylight.</summary>
|
||||
|
||||
Keep a low configured `min_brightness` for late night and let an automation lower `max_brightness` while the room has ample daylight. Use a sensor that is not significantly affected by the controlled lights to avoid a feedback loop.
|
||||
|
||||
```yaml
|
||||
- alias: "Adaptive lighting: limit brightness in daylight"
|
||||
triggers:
|
||||
- trigger: numeric_state
|
||||
entity_id: sensor.living_room_illuminance
|
||||
above: 300
|
||||
- trigger: numeric_state
|
||||
entity_id: sensor.living_room_illuminance
|
||||
below: 200
|
||||
- trigger: homeassistant
|
||||
event: start
|
||||
id: startup
|
||||
actions:
|
||||
- if:
|
||||
- condition: trigger
|
||||
id: startup
|
||||
then:
|
||||
- wait_template: >
|
||||
{{ is_number(states('sensor.living_room_illuminance')) }}
|
||||
timeout: "00:05:00"
|
||||
continue_on_timeout: false
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.living_room_illuminance
|
||||
above: 300
|
||||
sequence:
|
||||
- action: adaptive_lighting.change_switch_settings
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_living_room
|
||||
max_brightness: 30
|
||||
- conditions:
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.living_room_illuminance
|
||||
below: 200
|
||||
sequence:
|
||||
- action: adaptive_lighting.change_switch_settings
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_living_room
|
||||
max_brightness: 100
|
||||
mode: restart
|
||||
```
|
||||
|
||||
The separate 200 and 300 lux thresholds add hysteresis. After a restart, the automation waits for a numeric sensor state before evaluating it. If the initial value is between the thresholds, Adaptive Lighting keeps its configured maximum. Replace `30` and `100` with your desired daytime limit and normal maximum.
|
||||
|
||||
`min_brightness` and `max_brightness` are the solar-midnight and daytime endpoints of the brightness curve. Setting `min_brightness` higher than `max_brightness` is supported and creates an inverted curve that is brighter at night and dimmer during the day. If you only want a daytime limit, keep the reduced maximum at or above the configured minimum.
|
||||
|
||||
</details>
|
||||
|
||||
<details markdown="1">
|
||||
<summary>Turn on Hue-controlled lights with the current Adaptive Lighting values.</summary>
|
||||
|
||||
For a Hue button exposed to Home Assistant, call this script from the button automation. It turns on the listed lights directly with the current Adaptive Lighting brightness and color.
|
||||
|
||||
```yaml
|
||||
script:
|
||||
living_room_adaptive_lighting:
|
||||
alias: "Living room: adaptive lighting"
|
||||
sequence:
|
||||
- action: adaptive_lighting.apply
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_living_room
|
||||
lights:
|
||||
- light.living_room_ceiling
|
||||
- light.living_room_table
|
||||
turn_on_lights: true
|
||||
transition: 0
|
||||
```
|
||||
|
||||
This requires Home Assistant to receive the button event. The one-shot `apply` call works while the main Adaptive Lighting switch is off, turns on the listed lights, and applies values even if a light is marked as manually controlled. It leaves the profile switch and manual-control state unchanged.
|
||||
|
||||
Adaptive Lighting does not update scenes stored on the Hue Bridge, so scenes activated only inside Hue cannot use this script and retain Hue's operation when Home Assistant is unavailable.
|
||||
|
||||
</details>
|
||||
|
||||
<details markdown="1">
|
||||
<summary>Use a fixed RGB stage before sleep mode.</summary>
|
||||
|
||||
This script starts sleep mode with a fixed dim red color, waits 30 minutes, and then restores the configured Adaptive Lighting settings. The main profile switch and the light must already be on.
|
||||
|
||||
```yaml
|
||||
script:
|
||||
adaptive_lighting_bedtime:
|
||||
alias: "Adaptive lighting: bedtime"
|
||||
mode: restart
|
||||
sequence:
|
||||
- action: adaptive_lighting.change_switch_settings
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_bedroom
|
||||
sleep_rgb_or_color_temp: rgb_color
|
||||
sleep_rgb_color: [255, 56, 0]
|
||||
sleep_brightness: 20
|
||||
- action: switch.turn_on
|
||||
target:
|
||||
entity_id: switch.adaptive_lighting_bedroom_sleep_mode
|
||||
- delay: "00:30:00"
|
||||
- action: adaptive_lighting.change_switch_settings
|
||||
data:
|
||||
entity_id: switch.adaptive_lighting_bedroom
|
||||
use_defaults: configuration
|
||||
```
|
||||
|
||||
The light must support RGB color. The first stage uses a fixed brightness rather than following the normal brightness curve. When sleep mode changes from off to on, the default `reset_manual_control_on_sleep_mode_change: true` returns manually controlled lights to Adaptive Lighting control so they receive the stage. If you disable that option, manually controlled lights remain paused. Restoring configuration defaults resets every runtime setting on this Adaptive Lighting switch, so restore only the sleep fields explicitly if other automations also change runtime settings.
|
||||
|
||||
Stopping this script or reloading scripts during the delay prevents the final action, leaving the runtime overrides active. To recover, call `adaptive_lighting.change_switch_settings` for the profile with `use_defaults: configuration`. A Home Assistant restart reloads the configured settings.
|
||||
|
||||
</details>
|
||||
|
||||
<details markdown="1">
|
||||
<summary>Run a fixed virtual day across midnight.</summary>
|
||||
|
||||
Fixed virtual sunrise and sunset times can cross midnight. This configuration ramps an indoor garden from its minimum at 16:00 to its maximum at 22:00, then back to its minimum at 04:00.
|
||||
|
||||
```yaml
|
||||
adaptive_lighting:
|
||||
- name: "Indoor Garden"
|
||||
lights:
|
||||
- light.indoor_garden
|
||||
sunrise_time: "16:00:00"
|
||||
sunset_time: "04:00:00"
|
||||
min_brightness: 10
|
||||
max_brightness: 100
|
||||
brightness_mode: linear
|
||||
brightness_mode_time_dark: 0
|
||||
brightness_mode_time_light: 21600 # 6 hours
|
||||
```
|
||||
|
||||
Adaptive Lighting changes brightness and color while a light is on; it does not manage the light's power schedule. This separate automation turns the example light on and off:
|
||||
|
||||
```yaml
|
||||
- alias: "Indoor garden: power schedule"
|
||||
triggers:
|
||||
- trigger: time
|
||||
at: "16:00:00"
|
||||
id: turn_on
|
||||
- trigger: time
|
||||
at: "04:00:00"
|
||||
id: turn_off
|
||||
- trigger: homeassistant
|
||||
event: start
|
||||
id: startup
|
||||
actions:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: turn_on
|
||||
sequence:
|
||||
- action: light.turn_on
|
||||
target:
|
||||
entity_id: light.indoor_garden
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: startup
|
||||
- condition: time
|
||||
after: "16:00:00"
|
||||
before: "04:00:00"
|
||||
sequence:
|
||||
- action: light.turn_on
|
||||
target:
|
||||
entity_id: light.indoor_garden
|
||||
default:
|
||||
- action: light.turn_off
|
||||
target:
|
||||
entity_id: light.indoor_garden
|
||||
```
|
||||
|
||||
Use `min_sunrise_time`, `max_sunrise_time`, `min_sunset_time`, or `max_sunset_time` instead when you want to constrain astronomical sunrise or sunset to an earliest or latest time rather than replace it.
|
||||
|
||||
</details>
|
||||
|
||||
<!-- OUTPUT:END -->
|
||||
|
||||
> [!TIP]
|
||||
|
|
|
|||
|
|
@ -8,17 +8,11 @@ Adaptive Lighting supports configuration through both YAML and the Home Assistan
|
|||
|
||||
## Basic Configuration
|
||||
|
||||
The minimal configuration requires only adding the integration to your `configuration.yaml`:
|
||||
|
||||
```yaml
|
||||
adaptive_lighting:
|
||||
```
|
||||
|
||||
You can then configure everything through the UI at **Settings** → **Devices & Services** → **Adaptive Lighting** → **Configure**.
|
||||
The simplest setup uses the Home Assistant UI. Go to **Settings** → **Devices & Services** → **Add Integration** → **Adaptive Lighting**. No `adaptive_lighting:` entry is needed in `configuration.yaml`.
|
||||
|
||||
## YAML Configuration
|
||||
|
||||
For YAML configuration, you can specify lights and options directly:
|
||||
Alternatively, you can specify lights and options in `configuration.yaml`:
|
||||
|
||||
```yaml
|
||||
adaptive_lighting:
|
||||
|
|
@ -38,48 +32,49 @@ All configuration options are listed below with their default values. These opti
|
|||
<!-- CODE:END -->
|
||||
<!-- OUTPUT:START -->
|
||||
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
|
||||
| Variable name | Description | Default | Type |
|
||||
|:-------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------|:----------------------------------------|
|
||||
| `lights` | List of light entity_ids to be controlled (may be empty). 🌟 | `[]` | list of `entity_id`s |
|
||||
| `interval` | Frequency to adapt the lights, in seconds. 🔄 | `90` | `int > 0` |
|
||||
| `transition` | Duration of transition when lights change, in seconds. 🕑 | `45` | `float` 0-6553 |
|
||||
| `initial_transition` | Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️ | `1` | `float` 0-6553 |
|
||||
| `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 |
|
||||
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | `False` | `bool` |
|
||||
| `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 |
|
||||
| `sleep_transition` | Duration of transition when "sleep mode" is toggled in seconds. 😴 | `1` | `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` |
|
||||
| `sunrise_time` | Set a fixed time (HH:MM:SS) for sunrise. 🌅 | `None` | `str` |
|
||||
| `min_sunrise_time` | Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. 🌅 | `None` | `str` |
|
||||
| `max_sunrise_time` | Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier 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 sunsets. 🌇 | `None` | `str` |
|
||||
| `max_sunset_time` | Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. 🌇 | `None` | `str` |
|
||||
| `sunset_offset` | Adjust sunset time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
|
||||
| `brightness_mode` | Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). 📈 | `default` | one of `['default', 'linear', 'tanh']` |
|
||||
| `brightness_mode_time_dark` | (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness before/after sunrise/sunset. 📈📉 | `900` | `int` |
|
||||
| `brightness_mode_time_light` | (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness after/before sunrise/sunset. 📈📉. | `3600` | `int` |
|
||||
| `take_over_control` | Pause adaptation of individual lights and hand over (manual) control to other sources that issue `light.turn_on` calls for lights that are on. 🔒 | `True` | `bool` |
|
||||
| `take_over_control_mode` | The adaptation pausing mode when other sources change brightness and/or color of lights. `pause_all` always pauses both brightness and color adaptation. `pause_changed` pauses the adaptation of only the changed attributes and continues adapting unchanged attributes, e.g., continues color adaptation when only brightness was changed. | `pause_all` | one of `['pause_all', 'pause_changed']` |
|
||||
| `detect_non_ha_changes` | Detects and halts adaptations for non-`light.turn_on` state changes. Needs `take_over_control` enabled. 🕵️ Caution: ⚠️ Some lights might falsely indicate an 'on' state, which could result in lights turning on unexpectedly. Note that this calls `homeassistant.update_entity` every `interval`! Disable this feature if you encounter such issues. | `False` | `bool` |
|
||||
| `autoreset_control_seconds` | Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️ | `0` | `int` 0-31536000 |
|
||||
| `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄 | `False` | `bool` |
|
||||
| `adapt_only_on_bare_turn_on` | When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene and marks the light as manually controlled. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. 🕵️ | `False` | `bool` |
|
||||
| `adapt_only_on_ha_turn_on` | When a light turns on from `off`, only adapt it if Home Assistant issued the `light.turn_on`; lights turned on by a physical switch or an external scene (e.g. Lutron) are left untouched. Unlike disabling `detect_non_ha_changes`, this still detects manual changes to already-on lights. Needs `take_over_control` enabled. 🕵️ | `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` |
|
||||
| `skip_redundant_commands` | Skip sending adaptation commands whose target state already equals the light's known state. Minimizes network traffic and improves the adaptation responsivity in some situations. 📉Disable if physical light states get out of sync with HA's recorded state. | `False` | `bool` |
|
||||
| `intercept` | Intercept and adapt `light.turn_on` calls to enabling instantaneous color and brightness adaptation. 🏎️ Disable for lights that do not support `light.turn_on` with color and brightness. | `True` | `bool` |
|
||||
| `multi_light_intercept` | Intercept and adapt `light.turn_on` calls that target multiple lights. ➗⚠️ This might result in splitting up a single `light.turn_on` call into multiple calls, e.g., when lights are in different switches. Requires `intercept` to be enabled. | `True` | `bool` |
|
||||
| `include_config_in_attributes` | Show all options as attributes on the switch in Home Assistant when set to `true`. 📝 | `False` | `bool` |
|
||||
| Variable name | Description | Default | Type |
|
||||
|:--------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------|:----------------------------------------|
|
||||
| `lights` | List of light entity_ids to be controlled (may be empty). 🌟 | `[]` | list of `entity_id`s |
|
||||
| `interval` | Frequency to adapt the lights, in seconds. 🔄 | `90` | `int > 0` |
|
||||
| `transition` | Duration of transition when lights change, in seconds. 🕑 | `45` | `float` 0-6553 |
|
||||
| `initial_transition` | Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️ | `1` | `float` 0-6553 |
|
||||
| `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 |
|
||||
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | `False` | `bool` |
|
||||
| `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 |
|
||||
| `sleep_transition` | Duration of transition when "sleep mode" is toggled in seconds. 😴 | `1` | `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` |
|
||||
| `sunrise_time` | Set a fixed time (HH:MM:SS) for sunrise. 🌅 | `None` | `str` |
|
||||
| `min_sunrise_time` | Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. 🌅 | `None` | `str` |
|
||||
| `max_sunrise_time` | Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier 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 sunsets. 🌇 | `None` | `str` |
|
||||
| `max_sunset_time` | Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. 🌇 | `None` | `str` |
|
||||
| `sunset_offset` | Adjust sunset time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
|
||||
| `brightness_mode` | Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). 📈 | `default` | one of `['default', 'linear', 'tanh']` |
|
||||
| `brightness_mode_time_dark` | (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness before/after sunrise/sunset. 📈📉 | `900` | `int` |
|
||||
| `brightness_mode_time_light` | (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness after/before sunrise/sunset. 📈📉. | `3600` | `int` |
|
||||
| `take_over_control` | Pause adaptation of individual lights and hand over (manual) control to other sources that issue `light.turn_on` calls for lights that are on. 🔒 | `True` | `bool` |
|
||||
| `take_over_control_mode` | The adaptation pausing mode when other sources change brightness and/or color of lights. `pause_all` always pauses both brightness and color adaptation. `pause_changed` pauses the adaptation of only the changed attributes and continues adapting unchanged attributes, e.g., continues color adaptation when only brightness was changed. | `pause_all` | one of `['pause_all', 'pause_changed']` |
|
||||
| `detect_non_ha_changes` | Detects and halts adaptations for non-`light.turn_on` state changes. Needs `take_over_control` enabled. 🕵️ Caution: ⚠️ Some lights might falsely indicate an 'on' state, which could result in lights turning on unexpectedly. Note that this calls `homeassistant.update_entity` every `interval`! Disable this feature if you encounter such issues. | `False` | `bool` |
|
||||
| `autoreset_control_seconds` | Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️ | `0` | `int` 0-31536000 |
|
||||
| `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄 | `False` | `bool` |
|
||||
| `adapt_only_on_bare_turn_on` | When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene and marks the light as manually controlled. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. 🕵️ | `False` | `bool` |
|
||||
| `adapt_only_on_ha_turn_on` | Only adapt an `off` to `on` event when its context exactly matches the most recent Home Assistant `light.turn_on` context recorded for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This keeps `detect_non_ha_changes` available for lights that are already on. Some integrations do not preserve the service context in later state updates, so Adaptive Lighting cannot identify every physical versus Home Assistant turn-on source. Needs `take_over_control` enabled. 🕵️ | `False` | `bool` |
|
||||
| `reset_manual_control_on_sleep_mode_change` | Reset manual control when the sleep mode switch is toggled. Set to `false` to preserve manual control across sleep mode changes. 😴 | `True` | `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` |
|
||||
| `skip_redundant_commands` | Skip sending adaptation commands whose target state already equals the light's known state. Minimizes network traffic and improves the adaptation responsivity in some situations. 📉Disable if physical light states get out of sync with HA's recorded state. | `False` | `bool` |
|
||||
| `intercept` | Intercept and adapt `light.turn_on` calls to enabling instantaneous color and brightness adaptation. 🏎️ Disable for lights that do not support `light.turn_on` with color and brightness. | `True` | `bool` |
|
||||
| `multi_light_intercept` | Intercept and adapt `light.turn_on` calls that target multiple lights. ➗⚠️ This might result in splitting up a single `light.turn_on` call into multiple calls, e.g., when lights are in different switches. Requires `intercept` to be enabled. | `True` | `bool` |
|
||||
| `include_config_in_attributes` | Show all options as attributes on the switch in Home Assistant when set to `true`. 📝 | `False` | `bool` |
|
||||
|
||||
<!-- OUTPUT:END -->
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ This guide will help you install and configure Adaptive Lighting for the first t
|
|||
|
||||
## Prerequisites
|
||||
|
||||
- [Home Assistant](https://www.home-assistant.io/) 2024.12.0 or newer
|
||||
- [Home Assistant](https://www.home-assistant.io/) 2025.9.0 or newer
|
||||
- [HACS](https://hacs.xyz/) (Home Assistant Community Store) installed
|
||||
|
||||
## Installation
|
||||
|
|
@ -34,40 +34,23 @@ Or use this button to open HACS directly:
|
|||
|
||||
## Configuration
|
||||
|
||||
### Step 1: Add to configuration.yaml
|
||||
|
||||
Add the following to your `configuration.yaml`:
|
||||
|
||||
```yaml
|
||||
adaptive_lighting:
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> This entry is required even if you plan to configure everything through the UI.
|
||||
|
||||
### Step 2: Restart Home Assistant
|
||||
|
||||
Restart Home Assistant for the changes to take effect.
|
||||
|
||||
### Step 3: Add the Integration
|
||||
|
||||
1. Go to **Settings** → **Devices & Services**
|
||||
2. Click **+ Add Integration**
|
||||
3. Search for "Adaptive Lighting"
|
||||
4. Follow the setup wizard to select your lights
|
||||
|
||||
### Step 4: Configure Your Lights
|
||||
|
||||
You can configure Adaptive Lighting in two ways:
|
||||
Choose one of two configuration methods:
|
||||
|
||||
=== "Via UI"
|
||||
|
||||
1. Go to **Settings** → **Devices & Services**
|
||||
2. Find Adaptive Lighting and click **Configure**
|
||||
3. Adjust settings as needed
|
||||
2. Click **+ Add Integration**
|
||||
3. Search for "Adaptive Lighting"
|
||||
4. Follow the setup wizard to name your Adaptive Lighting instance
|
||||
5. Find Adaptive Lighting and click **Configure**
|
||||
6. Select your lights and adjust the settings
|
||||
|
||||
No `adaptive_lighting:` entry is needed in `configuration.yaml`.
|
||||
|
||||
=== "Via YAML"
|
||||
|
||||
Instances configured through YAML must be edited in YAML.
|
||||
|
||||
```yaml
|
||||
adaptive_lighting:
|
||||
- name: "Living Room"
|
||||
|
|
@ -80,7 +63,9 @@ You can configure Adaptive Lighting in two ways:
|
|||
max_color_temp: 5500
|
||||
```
|
||||
|
||||
## Basic Configuration Example
|
||||
Restart Home Assistant after changing the YAML configuration.
|
||||
|
||||
## Basic YAML Configuration Example
|
||||
|
||||
Here's a simple configuration to get you started:
|
||||
|
||||
|
|
|
|||
|
|
@ -46,19 +46,8 @@ Adaptive Lighting provides four switches (using "living_room" as an example comp
|
|||
## Quick Start
|
||||
|
||||
1. **Install via HACS**: Search for "Adaptive Lighting" in the [Home Assistant Community Store](https://hacs.xyz/)
|
||||
2. **Add to configuration**: Add `adaptive_lighting:` to your `configuration.yaml`
|
||||
3. **Configure**: Go to **Settings** → **Devices & Services** → **Add Integration** → **Adaptive Lighting**
|
||||
4. **Select your lights**: Choose which lights to control and enjoy automatic adaptation!
|
||||
|
||||
```yaml
|
||||
# Minimal configuration.yaml entry
|
||||
adaptive_lighting:
|
||||
lights:
|
||||
- light.living_room
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> **Using the UI exclusively?** Even if you plan to configure everything through the UI, the `adaptive_lighting:` entry must still be present in your `configuration.yaml`.
|
||||
2. **Add the integration**: Go to **Settings** → **Devices & Services** → **Add Integration** → **Adaptive Lighting**, then name your instance
|
||||
3. **Configure**: Open Adaptive Lighting, click **Configure**, select your lights, and adjust the settings. No YAML entry is needed.
|
||||
|
||||
[Get Started →](getting-started.md){ .md-button .md-button--primary }
|
||||
[View All Options →](configuration.md){ .md-button }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ Adaptive Lighting provides three services for programmatic control, allowing you
|
|||
## adaptive_lighting.apply
|
||||
|
||||
Applies the current Adaptive Lighting settings to lights on demand. Useful for forcing an immediate update or applying settings to lights that aren't in the regular adaptation cycle.
|
||||
Provide a switch in `entity_id`, a list of `lights`, or both.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ Applies the current Adaptive Lighting settings to lights on demand. Useful for f
|
|||
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
|
||||
| Service data attribute | Description | Required | Type |
|
||||
|:-------------------------|:--------------------------------------------------------------------------------------|:-----------|:---------------------|
|
||||
| `entity_id` | The `entity_id` of the switch with the settings to apply. 📝 | ✅ | list of `entity_id`s |
|
||||
| `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 |
|
||||
|
|
@ -58,6 +59,7 @@ data:
|
|||
## adaptive_lighting.set_manual_control
|
||||
|
||||
Marks or unmarks a light as "manually controlled". When a light is marked as manually controlled, Adaptive Lighting will not adjust it until the manual control flag is cleared.
|
||||
Provide a switch in `entity_id`, a list of `lights`, or both.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
|
@ -69,7 +71,7 @@ Marks or unmarks a light as "manually controlled". When a light is marked as man
|
|||
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
|
||||
| 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 |
|
||||
| `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") all adapted attributes of the light from the "manual_control" list, or the name of an attribute for selective addition. 🔒 | ❌ | bool or one of `['brightness', 'color']` |
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ Addressing these issues will significantly improve your Home Assistant experienc
|
|||
In case lights are suddenly turning on by themselves, this is most likely due to the light incorrectly reporting an "on" state to Home Assistant, leading to an undesired Adaptive Lighting action.
|
||||
To prevent adapting in cases *where the state of the light is suddenly "on" and only adapt if there is an associated `light.turn_on` service call*, set `detect_non_ha_changes: false`.
|
||||
|
||||
If turning a light on from *off* with a physical wall switch or a hub/manufacturer scene (e.g., Lutron, Caséta) makes Adaptive Lighting immediately override the brightness/color that source set — forcing you to set it a second time — and you still want to keep `detect_non_ha_changes: true` to catch manual changes to already-on lights, set `adapt_only_on_ha_turn_on: true`. Adaptive Lighting will then leave externally turned-on lights untouched (marking them `manual_control`) while continuing to adapt lights turned on through Home Assistant.
|
||||
To keep detecting manual changes to lights that are already on while leaving unmatched `off` to `on` state events unchanged, enable `adapt_only_on_ha_turn_on`. Matching uses the exact context of the most recently recorded `light.turn_on` call. Some integrations replace or omit that context, so Adaptive Lighting cannot distinguish every physical versus Home Assistant turn-on source.
|
||||
|
||||
#### :signal_strength: WiFi Networks
|
||||
|
||||
|
|
@ -97,6 +97,8 @@ These lights are known to exhibit disadvantageous behaviour due to firmware bugs
|
|||
- Ikea Tradfri bulbs/drivers (and related Ikea smart light products)
|
||||
- Unsupported simultaneous transition of brightness and color: When receiving such a command, they switch the brightness instantly and only transition the color. To get smooth transitions of both brightness and color, enable `separate_turn_on_commands`.
|
||||
- Unresponsiveness during color transitions: No other commands are processed during an ongoing color transition, e.g., turn-off commands are ignored and lights stay on despite being reported as off to Home Assistant. The default config with long transitions thus results in long periods of unresponsiveness. To work around this, disable transitions by setting `transition` to `0`, and increase the adaptation frequency by setting `interval` to a short time, e.g., `15` seconds, to retain the impression of smooth continuous adaptations. Keeping the `initial_transition` is recommended for a smooth fade-in (lights are usually not turned off momentarily after being turned on, in which case a short period of unresponsiveness is tolerable).
|
||||
- [Lonsonho ZB-RGBCW](https://www.zigbee2mqtt.io/devices/ZB-RGBCW.html#lonsonho-zb-rgbcw)
|
||||
- Some Zigbee2MQTT/eWeLight firmware combinations do not turn the bulb on when the initial `light.turn_on` call includes brightness or color, although later adjustments work. Disable `intercept` for affected bulbs.
|
||||
|
||||
<!-- OUTPUT:END -->
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue