forked from apollo1220/blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera_detection_notification.yaml
91 lines (87 loc) · 2.59 KB
/
camera_detection_notification.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
blueprint:
name: Camera Detection
description: ''
domain: automation
input:
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive
notifications
selector:
device:
integration: mobile_app
camera:
name: Camera
description: Camera for which this detection is running
selector:
entity:
domain: camera
person_sensor:
name: Person detection sensor
description: Binary sensor which is on when a person is detected
selector:
entity:
domain: binary_sensor
store_location:
name: Folder to store snapshots in
description: Folder within your www folder where snapshots should be stored. Do not include www directory.
default: 'doorbell'
selector:
text:
no_motion_wait:
name: Time between notifications (seconds)
description: Time in seconds to wait before sending another notification of motion (to avoid spamming).
default: 0
selector:
number:
min: 0
max: 300
unit_of_measurement: seconds
blocker_entity:
name: (OPTIONAL) Blocking person
description: If this person's state is home, it will prevent the automation from
running.
default:
selector:
entity:
domain: person
mode: single
max_exceeded: silent
variables:
notify_device: !input 'notify_device'
camera: !input 'camera'
blocker_entity: !input 'blocker_entity'
no_motion_wait: !input 'no_motion_wait'
store_location: !input 'store_location'
time_stamp: "{{ now().timestamp() }}"
trigger:
- platform: state
entity_id: !input person_sensor
from: 'off'
to: 'on'
id: person
condition:
- condition: template
value_template: '{{ (blocker_entity == none) or (states[blocker_entity].state !=
''home'') }}'
action:
- service: camera.snapshot
data:
filename: /config/www/{{store_location}}/snapshot_{{ time_stamp }}.jpg
target:
entity_id: !input 'camera'
- service: notify.mobile_app_{{ device_attr(notify_device, 'name').lower() |regex_replace(find=' ', replace='_', ignorecase=False) }}
data:
title: Camera Detection
message: "{{ state_attr(camera, 'friendly_name') }} has detected a {{trigger.id}}"
data:
image: /local/{{store_location}}/snapshot_{{ time_stamp }}.jpg
channel: Motion
importance: high
ttl: 0
priority: high
notification_icon: mdi:cctv
- condition: template
value_template: '{{ no_motion_wait != none }}'
- delay:
seconds: '{{ no_motion_wait | int }}'