157 lines
4.1 KiB
YAML
157 lines
4.1 KiB
YAML
blueprint:
|
|
name: Sequential Christmas Blink Loop (On, Off, Blink, Restore)
|
|
description: >
|
|
Turn selected lights on in sequence, then off in sequence, then
|
|
blink all lights N times, and keep repeating while an enable
|
|
helper is ON. When stopped, restore the initial state.
|
|
domain: automation
|
|
source_url: https://git.bedon.fr/bedweb/hablueprint/raw/branch/main/christmas_lights.yml
|
|
input:
|
|
enable_helper:
|
|
name: Enable switch
|
|
description: Helper (input_boolean) that enables/disables the effect.
|
|
selector:
|
|
entity:
|
|
domain: input_boolean
|
|
|
|
lights:
|
|
name: Lights (sequence order)
|
|
description: Select the lights; order here is the sequence order.
|
|
selector:
|
|
target:
|
|
entity:
|
|
domain: light
|
|
|
|
on_delay:
|
|
name: Delay between lights turning ON (s)
|
|
default: 0.5
|
|
selector:
|
|
number:
|
|
min: 0.1
|
|
max: 5
|
|
step: 0.1
|
|
mode: slider
|
|
|
|
off_delay:
|
|
name: Delay between lights turning OFF (s)
|
|
default: 0.5
|
|
selector:
|
|
number:
|
|
min: 0.1
|
|
max: 5
|
|
step: 0.1
|
|
mode: slider
|
|
|
|
blink_color:
|
|
name: Blink color (optional)
|
|
description: Leave as red or change as desired.
|
|
default: [255, 0, 0]
|
|
selector:
|
|
color_rgb: {}
|
|
|
|
blink_count:
|
|
name: Number of blinks after sequence
|
|
default: 2
|
|
selector:
|
|
number:
|
|
min: 1
|
|
max: 10
|
|
step: 1
|
|
|
|
blink_on_time:
|
|
name: Blink ON time (s)
|
|
default: 0.4
|
|
selector:
|
|
number:
|
|
min: 0.1
|
|
max: 5
|
|
step: 0.1
|
|
|
|
blink_off_time:
|
|
name: Blink OFF time (s)
|
|
default: 0.4
|
|
selector:
|
|
number:
|
|
min: 0.1
|
|
max: 5
|
|
step: 0.1
|
|
|
|
mode: restart
|
|
max_exceeded: silent
|
|
|
|
variables:
|
|
enable_helper: !input enable_helper
|
|
lights: !input lights
|
|
on_delay: !input on_delay
|
|
off_delay: !input off_delay
|
|
blink_color: !input blink_color
|
|
blink_count: !input blink_count
|
|
blink_on_time: !input blink_on_time
|
|
blink_off_time: !input blink_off_time
|
|
restore_scene_name: "seq_christmas_blink_restore"
|
|
|
|
trigger:
|
|
- platform: state
|
|
entity_id: !input enable_helper
|
|
to: "on"
|
|
|
|
condition: []
|
|
|
|
action:
|
|
# 0. Capture initial state as scene
|
|
- service: scene.create
|
|
data:
|
|
scene_id: "{{ restore_scene_name }}"
|
|
snapshot_entities: "{{ expand(lights.entity_id) | map(attribute='entity_id') | list }}"
|
|
|
|
- repeat:
|
|
while:
|
|
- condition: state
|
|
entity_id: !input enable_helper
|
|
state: "on"
|
|
sequence:
|
|
# Build an ordered list of light entity_ids
|
|
- variables:
|
|
light_list: "{{ expand(lights.entity_id) | map(attribute='entity_id') | list }}"
|
|
|
|
# 1. Turn lights ON in order with on_delay
|
|
- repeat:
|
|
count: "{{ light_list | length }}"
|
|
sequence:
|
|
- service: light.turn_on
|
|
target:
|
|
entity_id: "{{ light_list[repeat.index - 1] }}"
|
|
- delay:
|
|
seconds: "{{ on_delay | float }}"
|
|
|
|
# 2. Turn lights OFF in order with off_delay
|
|
- repeat:
|
|
count: "{{ light_list | length }}"
|
|
sequence:
|
|
- service: light.turn_off
|
|
target:
|
|
entity_id: "{{ light_list[repeat.index - 1] }}"
|
|
- delay:
|
|
seconds: "{{ off_delay | float }}"
|
|
|
|
# 3. Blink all lights together blink_count times
|
|
- repeat:
|
|
count: "{{ blink_count }}"
|
|
sequence:
|
|
- service: light.turn_on
|
|
target: !input lights
|
|
data:
|
|
rgb_color: "{{ blink_color }}"
|
|
brightness: 255
|
|
- delay:
|
|
seconds: "{{ blink_on_time | float }}"
|
|
- service: light.turn_off
|
|
target: !input lights
|
|
- delay:
|
|
seconds: "{{ blink_off_time | float }}"
|
|
|
|
# 4. Restore original state once helper goes OFF / automation stops
|
|
- service: scene.turn_on
|
|
target:
|
|
entity_id: "scene.{{ restore_scene_name }}"
|