In Home Assistant, I'm using automations and scripts to dynamically display who's at the door when the doorbell is pressed. The image pops-up in my persistent notification with an image of the person at the door. I've tested this on Amcrest and Reolink doorbells with success.
Prerequisite
Create a Text Helper in Home Assistant. Go to Settings > Devices & services > Helpers. Select + Create Helper at the bottom right. Choose Text. Give it a name such as "Snapshot Timestamp" and you'll reference this helper as input_text.snapshot_timestamp
.
In Automations
alias: Notification on doorbell pressed
description: Trigger notification when Amcrest button press event fires
trigger:
- platform: event
event_type: amcrest
event_data:
event: CallNoAnswered
payload:
action: Start
condition: []
action:
- service: script.notification_doorbell_pressed
data: {}
mode: single
In Scripts
alias: Notification - Doorbell Pressed
sequence:
- service: input_text.set_value
entity_id: input_text.snapshot_timestamp
data_template:
value: "{{ now().strftime('%Y%m%d_%H%M%S') }}"
- service: camera.snapshot
data:
entity_id: camera.front_door
filename: >-
/config/www/images/frontdoor-{{ states('input_text.snapshot_timestamp') }}.jpg
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: persistent_notification.create
data:
message: >-
Doorbell pressed at {{ states('sensor.date_time') }}. ![Front door
snapshot](/local/images/frontdoor-{{ states('input_text.snapshot_timestamp') }}.jpg)
title: Front Doorbell Ringing
- service: notify.pushover
data:
message: Doorbell pressed at {{ states('sensor.date_time') }}.
title: Front Doorbell Ringing
mode: single
icon: mdi:message
Let's breakdown what is happening in the script sequence:
service: input_text.set_value
Here we set the current date/time into the helper that we created earlier. We are referencing the helper by entity_id
named input_text.snapshot_timestamp
. We're going to use this variable throughout the script as the time in moment when the trigger occurred. Otherwise, if we call date/time in each of our sequence it would be offset by the time that has elapsed while running the script.
service: camera.snapshot
We're calling our Home Assistant device (aka the doorbell) to take a snapshot and saving it in /config/www/images
. Go ahead and create the sub-directories, www
and images
in config
if they do not already exist. NOTE that if your Home Assistant instance is opened up to the Internet that anything in www
will be accessible as well.
delay
Create a delay to allow processing of the snapshot.
persistent_notification.create
This is where we create our persistent notification with an image of who's at the door! We're using Markdown to display the image and linking to the snapshot that was created with the unique date/time that the doorbell was triggered. NOTE that anything in /config/www/
translates to /local/...
For example, if you created /config/www/1/2/
then you would call /local/1/2/
aka https://home_assistant_url:port/local/1/2/
service: notify.pushover
OPTIONAL. This is where I also send out notifications via Pushover to all my devices.
For Internal Use: \Machine Notes\Home Assistant Persistent Notification Standard