Last active
July 9, 2024 02:45
-
-
Save bob454522/3f6160823dead8516677c2d71fcd0f0d to your computer and use it in GitHub Desktop.
blueprint for HA blink
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: jo v5 Blink lights | |
author: Edward Firmo (https://github.com/edwardtfn) | |
homeassistant: | |
min_version: '2023.3.0' | |
description: Blink lights (w return light to prior level) (or a switch) when a trigger (binary-sensor) changes. | |
domain: automation | |
source_url: https://gist.github.com/bob454522/3f6160823dead8516677c2d71fcd0f0d | |
input: | |
trigger_entities: | |
name: Trigger entities | |
description: > | |
The lights/switches will "blink" if any of the entities selected here changes its state. | |
Try to avoid a big number of lights or groups as it can take long to change the state on all the entities. | |
default: [] | |
selector: | |
entity: | |
multiple: true | |
domain: [input_boolean, binary_sensor, switch] | |
entities_list: | |
name: Lights and switches to blink | |
default: [] | |
selector: | |
entity: | |
multiple: true | |
domain: [light, switch] | |
number_of_blinks: | |
name: Number of blinks | |
default: 3 | |
selector: | |
number: | |
min: 0 | |
max: 25 | |
unit_of_measurement: blinks | |
blink_duration: | |
name: Blink speed (msec) | |
description: > | |
The time (in milliseconds) the entities will stay on each state (on or off). | |
Try to increase this time if you are using too many lights or if you have a long transition time for the lights. | |
default: 1000 | |
selector: | |
number: | |
min: 50 | |
max: 5000 | |
unit_of_measurement: milliseconds | |
pause_entities: | |
name: (Optional) Pause update entities | |
description: > | |
You can select one or more entities to pause this automation. | |
If any of the selected entities is "On" or "True" the system won't blink the lights on a trigger. | |
You can use this to hold this automation when you have a party or you are not at home. | |
default: [] | |
selector: | |
entity: | |
multiple: true | |
domain: [input_boolean, binary_sensor, switch] | |
mode: single | |
trigger_variables: | |
input_pause_entities: !input pause_entities | |
input_pause_entities_selected: >- | |
{% if input_pause_entities %} | |
true | |
{% else %} | |
false | |
{% endif %} | |
trigger: | |
- platform: state | |
entity_id: !input trigger_entities | |
to: "off" | |
from: "on" | |
- platform: state | |
entity_id: !input trigger_entities | |
to: "on" | |
from: "off" | |
condition: | |
- condition: or | |
conditions: | |
- condition: template | |
value_template: >- | |
{{ ( input_pause_entities_selected == false ) }} | |
- condition: state | |
entity_id: !input pause_entities | |
state: "off" | |
variables: | |
repeat_count: !input number_of_blinks | |
action: | |
- variables: | |
entities_list: !input entities_list | |
initial_light_states: > | |
{%- set ns = namespace(data={}) -%} | |
{%- for entity_id in entities_list -%} | |
{%- set state = states(entity_id) -%} | |
{%- set brightness = state_attr(entity_id, 'brightness') | default(255) -%} | |
{%- set ns.data = ns.data.update({entity_id: {"state": state, "brightness": brightness}}) or ns.data -%} | |
{%- endfor -%} | |
{{ ns.data }} | |
- repeat: | |
count: "{{ repeat_count * 2 }}" | |
sequence: | |
- service: homeassistant.toggle | |
data: {} | |
target: | |
entity_id: !input entities_list | |
- delay: | |
hours: 0 | |
minutes: 0 | |
seconds: 0 | |
milliseconds: !input blink_duration | |
- repeat: | |
for_each: "{{ initial_light_states.keys() | list }}" | |
sequence: | |
- choose: | |
- conditions: | |
- condition: template | |
value_template: "{{ initial_light_states[item]['state'] == 'on' }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ item }}" | |
data: | |
brightness: "{{ initial_light_states[item]['brightness'] }}" | |
- conditions: | |
- condition: template | |
value_template: "{{ initial_light_states[item]['state'] == 'off' }}" | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: "{{ item }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment