forked from myGithub-Markus/home-assistant_blueprints
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflashing_lights.yaml
188 lines (183 loc) · 5.86 KB
/
flashing_lights.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
blueprint:
name: flashing lights
description: >
Flashing lights via on off and delay and finally restore the previous light states.
domain: automation
source_url: https://github.com/myGithub-Markus/home-assistant_blueprints/blob/main/flashing_lights.yaml
input:
activated:
name: Sensor
description: "Sensor to activate or deactivate flashing lights."
selector:
entity:
activated_states:
name: States to match with activated sensor (optional)
description: "A comma separated list of activated states."
default: "on"
activated_timeout:
name: (OPTIONAL) activated timeout
description: "Max time to leave flashing light during activated sensor state is true. '0' means no timeout is defined."
default: 0
selector:
number:
min: 1
max: 3600
unit_of_measurement: seconds
light_target:
name: Light
description: "To using lights"
selector:
target:
entity:
domain: light
color_rgb:
name: RGBColor
description: Choose the color for blinking lights
selector:
select:
options:
- white
- red
- green
- lime
- blue
- navy
- yellow
- orange
- turquoise
- violet
- magenta
- aliceblue
- antiquewhite
- aquamarine
- aqua
- cadetblue
- coral
- cornflowerblue
- crimson
- darkblue
- darkorange
- darkorchid
- darksalmon
- darkslategray
- deeppink
- darkviolet
- deepskyblue
- ghostwhite
- gold
- lawngreen
- lightcoral
- lightgreen
- lightseagreen
brightness_rgb:
name: (OPTIONAL) Light Brightness
description: Color Brigthness between 0 to 255
selector:
number:
min: 0
max: 255
unit_of_measurement: RGB
step: 1.0
mode: slider
scene_target:
name: Scene
default: scene.none
description: "To using scene"
selector:
entity:
domain: scene
delay:
name: (OPTIONAL) Delay
description: "Delay flashing lights"
default: 1000
selector:
number:
min: 0
max: 20000
unit_of_measurement: milliseconds
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: !input activated
variables:
activated: !input activated
activated_states_str: !input activated_states
activated_states: "{{ activated_states_str.split(',') | map('trim') | list }}"
activated_timeout: !input activated_timeout
delay: !input delay
scene_target: !input scene_target
condition: []
action:
- service: scene.create
data:
scene_id: all_lights_snapshot
snapshot_entities: >
{{ states.light | map(attribute='entity_id') | join(',') }}
- choose:
- conditions:
- "{{ scene_target == 'scene.none' }}"
sequence:
- service: light.turn_on
target: !input light_target
data:
color_name: !input color_rgb
brightness: !input brightness_rgb
- delay:
milliseconds: 1000
- repeat:
while:
- condition: template
value_template: >
{% set time_now = as_timestamp(now()) %}
{% set activated_last_changed = float(states[activated].last_changed.timestamp(),0) %}
{% set is_timed_out = false %}
{% if activated_timeout > 0 %}
{% set is_timed_out = (time_now - activated_last_changed) > activated_timeout %}
{% endif %}
{% set activated_state = 'unknown' %}
{% if activated is defined %}
{% set activated_state = states(activated) %}
{% endif %}
{{ activated_state in activated_states and not is_timed_out }}
sequence:
- delay:
milliseconds: >
{{ delay }}
- service: light.toggle
target: !input light_target
- service: scene.turn_on
data:
entity_id: scene.all_lights_snapshot
- conditions:
- "{{ scene_target != 'scene.none' }}"
sequence:
- repeat:
while:
- condition: template
value_template: >
{% set time_now = as_timestamp(now()) %}
{% set activated_last_changed = float(states[activated].last_changed.timestamp(),0) %}
{% set is_timed_out = false %}
{% if activated_timeout > 0 %}
{% set is_timed_out = (time_now - activated_last_changed) > activated_timeout %}
{% endif %}
{% set activated_state = 'unknown' %}
{% if activated is defined %}
{% set activated_state = states(activated) %}
{% endif %}
{{ activated_state in activated_states and not is_timed_out }}
sequence:
- service: scene.turn_on
entity_id: !input scene_target
- delay:
milliseconds: >
{{ delay }}
- service: light.turn_off
target: !input light_target
- delay:
milliseconds: >
{{ delay }}
- service: scene.turn_on
data:
entity_id: scene.all_lights_snapshot