Actualiser christmas_lights.yml
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
blueprint:
|
||||
name: Sequential Christmas Blink Loop
|
||||
name: Sequential Christmas Blink Loop (On, Off, Blink, Restore)
|
||||
description: >
|
||||
Turn selected lights on in sequence, then blink them twice, and
|
||||
keep repeating while an enable helper is ON.
|
||||
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://example.com/sequential-christmas-blink-loop
|
||||
source_url: https://git.bedon.fr/bedweb/hablueprint/raw/branch/main/christmas_lights.yml
|
||||
input:
|
||||
enable_helper:
|
||||
name: Enable switch
|
||||
@@ -12,6 +13,7 @@ blueprint:
|
||||
selector:
|
||||
entity:
|
||||
domain: input_boolean
|
||||
|
||||
lights:
|
||||
name: Lights (sequence order)
|
||||
description: Select the lights; order here is the sequence order.
|
||||
@@ -19,8 +21,9 @@ blueprint:
|
||||
target:
|
||||
entity:
|
||||
domain: light
|
||||
|
||||
on_delay:
|
||||
name: Delay between lights turning on (s)
|
||||
name: Delay between lights turning ON (s)
|
||||
default: 0.5
|
||||
selector:
|
||||
number:
|
||||
@@ -28,12 +31,24 @@ blueprint:
|
||||
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 empty for current color.
|
||||
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
|
||||
@@ -42,6 +57,7 @@ blueprint:
|
||||
min: 1
|
||||
max: 10
|
||||
step: 1
|
||||
|
||||
blink_on_time:
|
||||
name: Blink ON time (s)
|
||||
default: 0.4
|
||||
@@ -50,6 +66,7 @@ blueprint:
|
||||
min: 0.1
|
||||
max: 5
|
||||
step: 0.1
|
||||
|
||||
blink_off_time:
|
||||
name: Blink OFF time (s)
|
||||
default: 0.4
|
||||
@@ -66,10 +83,12 @@ 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
|
||||
@@ -79,15 +98,23 @@ trigger:
|
||||
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:
|
||||
# 1. Turn lights on in 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:
|
||||
@@ -97,7 +124,17 @@ action:
|
||||
- delay:
|
||||
seconds: "{{ on_delay | float }}"
|
||||
|
||||
# 2. Blink them blink_count times
|
||||
# 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:
|
||||
@@ -112,3 +149,8 @@ action:
|
||||
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 }}"
|
||||
|
||||
Reference in New Issue
Block a user