-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsecurity.yaml
executable file
·342 lines (287 loc) · 9.92 KB
/
security.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
##################################################
## Inputs
input_boolean:
disable_alarm_system:
#################################################################
## Sensors
binary_sensor:
#Sensative Strips BS
- platform: template
sensors:
frontdoor_contact:
device_class: opening
value_template: "{{ is_state('sensor.frontdoor_contact_access_control', '22') }}"
- platform: template
sensors:
sidedoor_contact:
device_class: opening
value_template: "{{ is_state('sensor.sidedoor_contact_access_control', '22') }}"
- platform: template
sensors:
backdoor_contact:
device_class: opening
value_template: "{{ is_state('sensor.backdoor_contact_access_control', '22') }}"
#################################################################
## Automations
automation:
# Auto set status for Armed Home
- alias: Auto Status - Armed Home
initial_state: True
trigger:
- platform: time
at: '00:00:01'
condition:
condition: and
conditions:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.user1_occupancy
state: 'on'
- condition: state
entity_id: binary_sensor.user2_occupancy
state: 'on'
- condition: state
entity_id: binary_sensor.user3_occupancy
state: 'on'
- condition: state
entity_id: binary_sensor.user4_occupancy
state: 'on'
- condition: state
entity_id: alarm_control_panel.main
state: disarmed
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
action:
service: alarm_control_panel.alarm_arm_home
entity_id: alarm_control_panel.main
# Trigger for Alarm Home
- alias: Alarm - Armed Home
initial_state: True
trigger:
- platform: state
entity_id: binary_sensor.frontdoor_contact, binary_sensor.sidedoor_contact, binary_sensor.backdoor_contact
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
- condition: state
entity_id: alarm_control_panel.main
state: armed_home
action:
service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.main
# Auto rearm for Armed Home (when someone comes home)
- alias: Auto Status - Rearm Home
initial_state: True
trigger:
- platform: state
entity_id: binary_sensor.user1_occupancy, binary_sensor.user2_occupancy, binary_sensor.user3_occupancy, binary_sensor.user4_occupancy
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: time
after: '00:00:01'
before: '04:55:00'
- condition: or
conditions:
- condition: state
entity_id: alarm_control_panel.main
state: pending
- condition: state
entity_id: alarm_control_panel.main
state: armed_home
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
- condition: template
value_template: "{{ (as_timestamp(now())-as_timestamp(states.binary_sensor.user1_occupancy.last_changed)) > 600 }}"
- condition: template
value_template: "{{ (as_timestamp(now())-as_timestamp(states.binary_sensor.user2_occupancy.last_changed)) > 600 }}"
- condition: template
value_template: "{{ (as_timestamp(now())-as_timestamp(states.binary_sensor.user3_occupancy.last_changed)) > 600 }}"
- condition: template
value_template: "{{ (as_timestamp(now())-as_timestamp(states.binary_sensor.user4_occupancy.last_changed)) > 600 }}"
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.main
- delay: '00:01:00'
- service: alarm_control_panel.alarm_arm_home
entity_id: alarm_control_panel.main
# Auto Disarm for Armed Home
- alias: Auto Status - Disarm Home
initial_state: True
trigger:
- platform: time
at: '05:00:00'
condition:
- condition: state
entity_id: alarm_control_panel.main
state: armed_home
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.main
# Auto set status for Armed Away
- alias: Auto Status - Armed Away
initial_state: True
trigger:
- platform: state
entity_id: binary_sensor.user1_occupancy, binary_sensor.user2_occupancy, binary_sensor.user3_occupancy, binary_sensor.user4_occupancy
from: 'on'
to: 'off'
condition:
condition: and
conditions:
- condition: or
conditions:
- condition: state
entity_id: alarm_control_panel.main
state: disarmed
- condition: state
entity_id: alarm_control_panel.main
state: armed_home
- condition: state
entity_id: binary_sensor.user1_occupancy
state: 'off'
- condition: state
entity_id: binary_sensor.user2_occupancy
state: 'off'
- condition: state
entity_id: binary_sensor.user3_occupancy
state: 'off'
- condition: state
entity_id: binary_sensor.user4_occupancy
state: 'off'
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
action:
service: alarm_control_panel.alarm_arm_away
entity_id: alarm_control_panel.main
# Trigger for Alarm Away
- alias: Alarm - Armed Away
initial_state: True
trigger:
- platform: state
entity_id: binary_sensor.frontdoor_contact, binary_sensor.sidedoor_contact, binary_sensor.backdoor_contact, binary_sensor.hallway_motion1_sensor, binary_sensor.hallway_motion2_sensor, binary_sensor.uplivingroom_motion_sensor, binary_sensor.upoffice_motion_sensor
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
- condition: state
entity_id: alarm_control_panel.main
state: armed_away
action:
service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.main
# Auto disarm for Armed Away
- alias: Auto Status - Disarmed Away
initial_state: True
trigger:
- platform: state
entity_id: binary_sensor.user1_occupancy, binary_sensor.user2_occupancy, binary_sensor.user3_occupancy, binary_sensor.user4_occupancy
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
- condition: or
conditions:
- condition: state
entity_id: alarm_control_panel.main
state: pending
- condition: state
entity_id: alarm_control_panel.main
state: armed_away
- condition: state
entity_id: alarm_control_panel.main
state: triggered
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.main
# Disable alarm
- alias: Disable Alarm System
initial_state: True
trigger:
- platform: state
entity_id: input_boolean.disable_alarm_system
from: 'off'
to: 'on'
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.main
# Disarm when notifcation clicked
- alias: Notifcation Disarm
initial_state: True
trigger:
- platform: event
event_type: html5_notification.clicked
event_data:
action: disarm_ha
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.main
# Notification when alarm triggerd
- alias: Notify when alarm is triggered
initial_state: True
trigger:
- platform: state
entity_id: alarm_control_panel.main
from: 'pending'
to: 'triggered'
action:
- service: notify.html5
data:
title: 'ALARM! - {{now().strftime("%l:%M %P")}}'
message: "ALARM! Your home alarm has been triggered."
data:
image: !secret frontdoorimage
requireInteraction: true
renotify: true
tag: 'ha_alarm'
url: '/lovelace/security'
actions:
- action: 'disarm_ha'
title: 'Disarm'
- service: notify.twilio_calling
data:
message: 'Your home assistant security alarm has been triggered.'
target:
- !secret notificationtarget
# Notification when alarm disarmed
- alias: Notify when alarm is disarmed
initial_state: True
trigger:
- platform: state
entity_id: alarm_control_panel.main
from: 'triggered'
to: 'disarmed'
condition:
- condition: state
entity_id: input_boolean.disable_alarm_system
state: 'off'
action:
- service: notify.html5
data:
title: 'Disarmed - {{now().strftime("%l:%M %P")}}'
message: "Your home alarm has been disarmed."
data:
requireInteraction: false
renotify: false
silent: true
noscreen: true
tag: 'ha_alarm'
url: '/lovelace/security'