I have an EUFY video doorbell (but this should work with any HA supported doorbell) and also several Tapo C310 and EzViz cams.
Whenever these camera’s trigger a motion (or button push from the doorbell), it starts recording video for about 1 minute, and store them on the HA internal disc
(or mounted NAS or so …)
On connected devices, it will popup a screen, with a live-view of the camera that triggered the motion, and this popup will also disappear after one minute.
Also, I have an automation running that deletes old recordings (you can set retain-period), so you don’t have to do this manually.
And of course, we have a separate recording-view in our HA, on which we can browse/play previous recordings, accompanied with the timestamp and type of camera (front/back/doorbell …)
1. Prerequisites:
-You will need to install a plugin for you camera(s), this installation depends on the brand/type of camera you use. Look in the Home assistant forums for help on this.
– You need to install “custom:gallery-card” and also need to setup “the files component” and configure your “media source”. Look here for installation: https://github.com/TarheelGrad1998/gallery-card
2. My configuration:
I did setup the following media source, within my configuration.yaml:
(Those files need to be in the WWW subfolder, otherwise they will not be accessible from the web-interface !)
media_dirs:
local: /media
cameras: /config/www/cameras
I reboot my HA-instance every night, I have an automation that does this, and inside this automation, I also call a script to delete old camera-files.
This is done with the following automation in my configuration.yaml:
-The /config/www/cameras, correspond to the definition in the media-source.
-The 20, indicates to delete all files that are older then 20 days. (Replace this with a number to your likings)
delete_old_camera_files: find /config/www/cameras/* -mtime +20 -exec rm {} \;
Furthermore, there are the automations itself, for the camera/doorbell.
Simply add a trigger for motion detection on the camera, and doorbell press, and add the following “logic” in the action:
if:
- condition: trigger
id: cam_XXX
then:
- service: camera.record
data:
filename: >-
/config/www/cameras/{{ now().strftime("%Y-%m-%d - %H:%M:%S")}} - cam XXX.mp4
duration: 60
target:
entity_id: camera.camera_XXX
- service: browser_mod.more_info
data:
entity: camera.camera_XXX
large: true
ignore_popup_card: false
- service: media_player.play_media
data:
enqueue: play
media_content_type: music
media_content_id: /local/sounds/notification_camera.mp3
target:
entity_id: media_player.kitchen_google_home_mini
- service: camera.play_stream
data:
media_player: media_player.nesthub_bedroom_kris
target:
entity_id: camera.camera_XXX
- service: camera.play_stream
data:
media_player: media_player.nesthub_bedroom_christel
target:
entity_id: camera.camera_XXX
- delay:
hours: 0
minutes: 0
seconds: 55
milliseconds: 0
- service: media_player.media_stop
data: {}
target:
entity_id:
- media_player.nesthub_bedroom_kris
- media_player.nesthub_bedroom_christel
- service: media_player.turn_off
data: {}
target:
entity_id:
- media_player.nesthub_bedroom_kris
- media_player.nesthub_bedroom_christel
- service: browser_mod.close_popup
data: {}
What this automation does:
– Start the recording (for 60 seconds), based on a trigger of camera_XXX in the media-source folder, with a timestamp and camera ID in the filename.
– Put a large live-view of the camera, on every registered screen in browser_mod.
– Play a notification sound, on the google nest in our kitchen.
– Play the livestream on the 2 nest hub screen we have in the bedroom. (one on each side of the bed)
– After one minute, stop the camera recording, and close all live-views. (both the ones via browser_mod and the google nest hub screens)
3. The recording view
To get a preview-list with all recordings (like in the first screen), simply add a custom card, with the following definition:
type: custom:gallery-card
title: null
parsed_date_sort: true
caption_leading_zeros: true
show_reload: false
entities:
- path: media-source://media_source/cameras/
maximum_files: '50'
menu_alignment: left
card_mod:
style: |
ha-card {
color: #FFFFFF;
font-size: 12px;
aspect-ratio: 9/5
}
This will show the last 50 recordings from the “media-source”-folder, the most recent op top, showing the list on the left … 🙂