Actualiser christmas_lights.yml
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
blueprint:
|
blueprint:
|
||||||
name: Sequential Christmas Blink Loop
|
name: Sequential Christmas Blink Loop (On, Off, Blink, Restore)
|
||||||
description: >
|
description: >
|
||||||
Turn selected lights on in sequence, then blink them twice, and
|
Turn selected lights on in sequence, then off in sequence, then
|
||||||
keep repeating while an enable helper is ON.
|
blink all lights N times, and keep repeating while an enable
|
||||||
|
helper is ON. When stopped, restore the initial state.
|
||||||
domain: automation
|
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:
|
input:
|
||||||
enable_helper:
|
enable_helper:
|
||||||
name: Enable switch
|
name: Enable switch
|
||||||
@@ -12,6 +13,7 @@ blueprint:
|
|||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: input_boolean
|
domain: input_boolean
|
||||||
|
|
||||||
lights:
|
lights:
|
||||||
name: Lights (sequence order)
|
name: Lights (sequence order)
|
||||||
description: Select the lights; order here is the sequence order.
|
description: Select the lights; order here is the sequence order.
|
||||||
@@ -19,8 +21,9 @@ blueprint:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: light
|
domain: light
|
||||||
|
|
||||||
on_delay:
|
on_delay:
|
||||||
name: Delay between lights turning on (s)
|
name: Delay between lights turning ON (s)
|
||||||
default: 0.5
|
default: 0.5
|
||||||
selector:
|
selector:
|
||||||
number:
|
number:
|
||||||
@@ -28,12 +31,24 @@ blueprint:
|
|||||||
max: 5
|
max: 5
|
||||||
step: 0.1
|
step: 0.1
|
||||||
mode: slider
|
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:
|
blink_color:
|
||||||
name: Blink color (optional)
|
name: Blink color (optional)
|
||||||
description: Leave empty for current color.
|
description: Leave as red or change as desired.
|
||||||
default: [255, 0, 0]
|
default: [255, 0, 0]
|
||||||
selector:
|
selector:
|
||||||
color_rgb: {}
|
color_rgb: {}
|
||||||
|
|
||||||
blink_count:
|
blink_count:
|
||||||
name: Number of blinks after sequence
|
name: Number of blinks after sequence
|
||||||
default: 2
|
default: 2
|
||||||
@@ -42,6 +57,7 @@ blueprint:
|
|||||||
min: 1
|
min: 1
|
||||||
max: 10
|
max: 10
|
||||||
step: 1
|
step: 1
|
||||||
|
|
||||||
blink_on_time:
|
blink_on_time:
|
||||||
name: Blink ON time (s)
|
name: Blink ON time (s)
|
||||||
default: 0.4
|
default: 0.4
|
||||||
@@ -50,6 +66,7 @@ blueprint:
|
|||||||
min: 0.1
|
min: 0.1
|
||||||
max: 5
|
max: 5
|
||||||
step: 0.1
|
step: 0.1
|
||||||
|
|
||||||
blink_off_time:
|
blink_off_time:
|
||||||
name: Blink OFF time (s)
|
name: Blink OFF time (s)
|
||||||
default: 0.4
|
default: 0.4
|
||||||
@@ -66,10 +83,12 @@ variables:
|
|||||||
enable_helper: !input enable_helper
|
enable_helper: !input enable_helper
|
||||||
lights: !input lights
|
lights: !input lights
|
||||||
on_delay: !input on_delay
|
on_delay: !input on_delay
|
||||||
|
off_delay: !input off_delay
|
||||||
blink_color: !input blink_color
|
blink_color: !input blink_color
|
||||||
blink_count: !input blink_count
|
blink_count: !input blink_count
|
||||||
blink_on_time: !input blink_on_time
|
blink_on_time: !input blink_on_time
|
||||||
blink_off_time: !input blink_off_time
|
blink_off_time: !input blink_off_time
|
||||||
|
restore_scene_name: "seq_christmas_blink_restore"
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
- platform: state
|
||||||
@@ -79,15 +98,23 @@ trigger:
|
|||||||
condition: []
|
condition: []
|
||||||
|
|
||||||
action:
|
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:
|
- repeat:
|
||||||
while:
|
while:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: !input enable_helper
|
entity_id: !input enable_helper
|
||||||
state: "on"
|
state: "on"
|
||||||
sequence:
|
sequence:
|
||||||
# 1. Turn lights on in sequence
|
# Build an ordered list of light entity_ids
|
||||||
- variables:
|
- variables:
|
||||||
light_list: "{{ expand(lights.entity_id) | map(attribute='entity_id') | list }}"
|
light_list: "{{ expand(lights.entity_id) | map(attribute='entity_id') | list }}"
|
||||||
|
|
||||||
|
# 1. Turn lights ON in order with on_delay
|
||||||
- repeat:
|
- repeat:
|
||||||
count: "{{ light_list | length }}"
|
count: "{{ light_list | length }}"
|
||||||
sequence:
|
sequence:
|
||||||
@@ -97,7 +124,17 @@ action:
|
|||||||
- delay:
|
- delay:
|
||||||
seconds: "{{ on_delay | float }}"
|
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:
|
- repeat:
|
||||||
count: "{{ blink_count }}"
|
count: "{{ blink_count }}"
|
||||||
sequence:
|
sequence:
|
||||||
@@ -112,3 +149,8 @@ action:
|
|||||||
target: !input lights
|
target: !input lights
|
||||||
- delay:
|
- delay:
|
||||||
seconds: "{{ blink_off_time | float }}"
|
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