Add data-driven blueprint architecture for adaptive lighting modes

Implement three core blueprints using convention-based entity lookup:
- apply_lighting_mode: Dynamic mode application with behavior polymorphism
- weekend_mode_schedule: Auto-enable/disable based on day of week
- weekend_mode_apply_settings: Apply AL adjustments for weekends

Blueprints use convention over configuration, allowing unlimited custom
modes without code changes. Modes discovered via naming pattern:
input_text.adaptive_lighting_settings_{{mode}}
This commit is contained in:
2025-12-21 17:44:15 -08:00
parent d486f20378
commit 8f2bce6759
6 changed files with 223 additions and 395 deletions

View File

@@ -0,0 +1,92 @@
blueprint:
name: Apply Lighting Mode Settings
description: Data-driven mode application using convention-based entity lookup
domain: automation
input:
mode_input_select:
name: Mode Input Select
description: Dropdown helper tracking current lighting mode
selector:
entity:
domain: input_select
adaptive_lighting_switch:
name: Adaptive Lighting Switch
description: AL switch for this room
selector:
entity:
domain: switch
integration: adaptive_lighting
led_color_entity:
name: LED Color Entity (Optional)
description: Number entity for LED color (e.g., Inovelli switch)
default: {}
selector:
entity:
domain: number
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input mode_input_select
- platform: homeassistant
event: start
variables:
mode_select: !input mode_input_select
al_switch: !input adaptive_lighting_switch
led_entity: !input led_color_entity
mode: "{{ states(mode_select) }}"
settings_entity: >-
input_text.adaptive_lighting_settings_{{ mode | lower | replace(' ', '_') }}
settings: "{{ states(settings_entity) | from_json }}"
behavior: "{{ settings.behavior | default('adaptive_lighting') }}"
manual_control: "{{ settings.manual_control | default(false) }}"
al_config: "{{ settings.al_config | default({}) }}"
led_color: "{{ settings.led_color | default(170) }}"
action:
# Always set manual_control state based on mode settings
- service: adaptive_lighting.set_manual_control
data:
entity_id: "{{ al_switch }}"
manual_control: "{{ manual_control }}"
# Execute behavior-specific actions
- choose:
# Behavior: adaptive_lighting
- conditions: "{{ behavior == 'adaptive_lighting' }}"
sequence:
- service: adaptive_lighting.change_switch_settings
target:
entity_id: "{{ al_switch }}"
data: "{{ al_config | combine({'use_defaults': 'current'}) }}"
# Behavior: scene
- conditions: "{{ behavior == 'scene' }}"
sequence:
- service: scene.turn_on
target:
entity_id: "{{ settings.scene_entity }}"
# Behavior: script
- conditions: "{{ behavior == 'script' }}"
sequence:
- service: script.turn_on
target:
entity_id: "{{ settings.script_entity }}"
# Update LED color if entity provided
- if:
- condition: template
value_template: "{{ led_entity not in [none, {}, ''] }}"
then:
- service: number.set_value
target:
entity_id: "{{ led_entity }}"
data:
value: "{{ led_color }}"

View File

@@ -0,0 +1,85 @@
blueprint:
name: Weekend Mode Apply Settings
description: Adjust AL settings when weekend mode toggles
domain: automation
input:
weekend_mode_boolean:
name: Weekend Mode Boolean
description: Toggle helper for weekend mode
selector:
entity:
domain: input_boolean
adaptive_lighting_switch:
name: Adaptive Lighting Switch
description: AL switch to adjust
selector:
entity:
domain: switch
integration: adaptive_lighting
sunrise_time:
name: Weekend Sunrise Time
description: Delayed sunrise time for weekends
default: "10:00:00"
selector:
time:
sunset_time:
name: Weekend Sunset Time
description: Extended sunset time for weekends
default: "01:00:00"
selector:
time:
max_brightness:
name: Weekend Max Brightness
description: Reduced max brightness for weekends
default: 60
selector:
number:
min: 1
max: 100
step: 1
unit_of_measurement: "%"
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input weekend_mode_boolean
- platform: homeassistant
event: start
variables:
weekend_boolean: !input weekend_mode_boolean
al_switch: !input adaptive_lighting_switch
sunrise_time: !input sunrise_time
sunset_time: !input sunset_time
max_brightness: !input max_brightness
weekend_active: "{{ is_state(weekend_boolean, 'on') }}"
action:
- choose:
# Weekend mode ON - Apply adjustments
- conditions: "{{ weekend_active }}"
sequence:
- service: adaptive_lighting.change_switch_settings
target:
entity_id: "{{ al_switch }}"
data:
sunrise_time: "{{ sunrise_time }}"
sunset_time: "{{ sunset_time }}"
max_brightness: "{{ max_brightness }}"
use_defaults: current
# Weekend mode OFF - Reset to defaults
- conditions: "{{ not weekend_active }}"
sequence:
- service: adaptive_lighting.change_switch_settings
target:
entity_id: "{{ al_switch }}"
data:
use_defaults: configuration

View File

@@ -0,0 +1,46 @@
blueprint:
name: Weekend Mode Schedule
description: Auto-enable/disable weekend mode based on day of week
domain: automation
input:
weekend_mode_boolean:
name: Weekend Mode Boolean
description: Toggle helper for weekend mode
selector:
entity:
domain: input_boolean
toggle_time:
name: Toggle Time
description: Time to check and toggle weekend mode
default: "22:00:00"
selector:
time:
mode: single
max_exceeded: silent
trigger:
- platform: time
at: !input toggle_time
action:
- choose:
# Friday/Saturday - Enable weekend mode
- conditions:
- condition: time
weekday: [fri, sat]
sequence:
- service: input_boolean.turn_on
target:
entity_id: !input weekend_mode_boolean
# Sunday-Thursday - Disable weekend mode
- conditions:
- condition: time
weekday: [sun, mon, tue, wed, thu]
sequence:
- service: input_boolean.turn_off
target:
entity_id: !input weekend_mode_boolean