Requires a camera and two binary sensors for person and vehicle detection. Will send a notification to the selected device that has the Home Assistant app installed and that notification will include a snapshot from the camera at the time of detection. You may need to add the folder ‘doorbell’ to your ‘www’ folder for the snapshots to be stored.
Optionally you can configure a timeout between notifications to avoid spamming. And you can optionally set a binary sensor to prevent notifications while at home, asleep or whatever.
Updated: Added option for specifying the directory for storing the camera snapshot
Updated (2023/01/15): Fixed issue with notification device name containing spaces
Updates (2024/04/06): Made vehicle sensor optional and added an optional pet sensor
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 }}'