Last active
February 15, 2025 19:47
-
-
Save logikal/54b70b651006e209dc078cc5da0c04c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: WLED Notifier | |
description: Temporarily changes WLED lights for notifications and restores their previous state. | |
domain: automation | |
input: | |
lights: | |
name: WLED Lights | |
description: List of WLED light entities to notify | |
selector: | |
target: | |
entity: | |
domain: light | |
color: | |
name: Color | |
description: RGB color for the notification | |
default: [ 255, 0, 0 ] | |
selector: | |
color_rgb: {} | |
effect: | |
name: Effect | |
description: WLED effect name | |
default: "Solid" | |
selector: | |
text: {} | |
duration: | |
name: Duration | |
description: Duration in seconds for the notification | |
default: 30 | |
selector: | |
number: | |
min: 1 | |
max: 3600 | |
unit_of_measurement: seconds | |
brightness: | |
name: Brightness | |
description: Brightness percentage | |
default: 100 | |
selector: | |
number: | |
min: 1 | |
max: 100 | |
unit_of_measurement: '%' | |
wait_for_entity: | |
name: Wait for Entity | |
description: Entity or list of entities to wait for state change (optional) | |
default: [] | |
selector: | |
target: | |
entity: {} | |
wait_for_state: | |
name: Wait for State | |
description: State to wait for | |
default: "off" | |
selector: | |
text: {} | |
trigger: | |
- trigger: event | |
event_type: automation.trigger | |
variables: | |
lights: !input lights | |
color: !input color | |
effect: !input effect | |
duration: !input duration | |
brightness: !input brightness | |
wait_for_entity: !input wait_for_entity | |
wait_for_state: !input wait_for_state | |
action: | |
# Take a snapshot of current states BEFORE any changes | |
- alias: "Take snapshot" | |
action: scene.create | |
data: | |
scene_id: wled_notification_snapshot | |
snapshot_entities: "{{ lights.entity_id }}" | |
# Short delay to ensure snapshot is complete | |
- delay: | |
milliseconds: 100 | |
# Set the notification state (combining color and effect in one call) | |
- alias: "Set notification" | |
action: light.turn_on | |
target: !input lights | |
data: | |
brightness_pct: "{{ brightness }}" | |
rgb_color: "{{ color }}" | |
effect: "{{ effect }}" | |
# Choose between timed wait or condition wait | |
- alias: "Wait for condition or timeout" | |
choose: | |
- conditions: | |
- condition: template | |
value_template: "{{ wait_for_entity.entity_id | default([]) | length > 0 }}" | |
sequence: | |
- repeat: | |
while: | |
- condition: template | |
value_template: > | |
{% set target_entities = wait_for_entity.entity_id | default([]) %} {% set any_not_in_state = false %} {% if target_entities is string %} | |
{% set target_entities = [target_entities] %} | |
{% endif %} {% for entity_id in target_entities %} | |
{% if not is_state(entity_id, wait_for_state) %} | |
{% set any_not_in_state = true %} | |
{% endif %} | |
{% endfor %} {{ any_not_in_state }} | |
sequence: | |
- wait_template: > | |
{% set target_entities = wait_for_entity.entity_id | default([]) %} {% set all_in_state = true %} {% if target_entities is string %} | |
{% set target_entities = [target_entities] %} | |
{% endif %} {% for entity_id in target_entities %} | |
{% if not is_state(entity_id, wait_for_state) %} | |
{% set all_in_state = false %} | |
{% endif %} | |
{% endfor %} {{ all_in_state }} | |
timeout: "00:00:10" | |
continue_on_timeout: true | |
default: | |
- delay: | |
seconds: "{{ duration }}" | |
# Restore previous states | |
- alias: "Restore previous state" | |
action: scene.turn_on | |
target: | |
entity_id: scene.wled_notification_snapshot | |
# Clean up the scene | |
- alias: "Clean up" | |
action: scene.delete | |
data: | |
entity_id: scene.wled_notification_snapshot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment