-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathcamera_detection_notification.yaml
109 lines (109 loc) · 3.52 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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
vehicle_sensor:
name: (OPTIONAL) Vehicle detection sensor
description: Binary sensor which is on when a vehicle is detected
default:
selector:
entity:
domain: binary_sensor
pet_sensor:
name: (OPTIONAL) Pet detection sensor
description: Binary sensor which is on when a pet is detected
default:
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 entity
description: If this entity's state is on, it will prevent the automation from
running. E.g. sleepmode or away mode.
default:
selector:
entity:
domain: binary_sensor
source_url: https://github.com/apollo1220/blueprints/blob/main/camera_detection_notification.yaml
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'
trigger_variables:
vehicle_sensor: !input 'vehicle_sensor'
pet_sensor: !input 'pet_sensor'
trigger:
- platform: state
entity_id: !input 'person_sensor'
from: 'off'
to: 'on'
id: 'person'
- platform: template
value_template: "{{ is_state ( vehicle_sensor , 'on' ) }}"
id: 'vehicle'
- platform: template
value_template: "{{ is_state ( pet_sensor , 'on' ) }}"
id: 'pet'
condition:
- condition: template
value_template: '{{ (blocker_entity == none) or (states[blocker_entity].state == ''off'') }}'
action:
- service: camera.snapshot
data:
filename: /config/www/{{store_location}}/{{ trigger.to_state.last_changed | as_timestamp | timestamp_custom("%Y-%m-%d_%H-%M-%S") }}.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}}/{{ trigger.to_state.last_changed | as_timestamp | timestamp_custom("%Y-%m-%d_%H-%M-%S") }}.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 }}'