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:
92
blueprints/automation/apply_lighting_mode.yaml
Normal file
92
blueprints/automation/apply_lighting_mode.yaml
Normal 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 }}"
|
||||
Reference in New Issue
Block a user