I’ve trying to set Home Assistant up to take snapshots from my CCTV system when a motion sensor is triggered, so that I can display them on a Lovelace card rather than accessing them through the camera’s app.
I want to take three pictures a short time apart so that I can see someone when they first come into view, and then again as they get closer to the camera.
I’m recording video as well, but I want something that will load faster if I’m in an area with no wifi and which doesn’t need the camera’s own app to view it.
I used to just email the pictures to myself using the SMTP integration, but my email provider is going to change the security requirements soon to one that’s not compatible with the integration, so I’m looking for another way to view the images.
I’m currently using the code below to tell Home Assistant what I want my snapshots to be called, and where I want to save them.
I’m basically just repeating the same code three different times with a delay in between so that the files have slightly different names based on the time that they were taken being slightly different.
This code tells a text helper what name to give my snapshot
metadata: {}
data:
value: cam1_1 {{now().strftime("%Y%m%d-%H%M%S")}}.jpg
target:
entity_id: input_text.snapshot_name_cam1_1
action: input_text.set_value
I have a different helper for each of the three images, and for each camera on my network
snapshot_name_cam1_1
snapshot_name_cam1_2
snapshot_name_cam1_3
I’m using this code to take the snapshot, and to save it to the file name specified in the text helper above
metadata: {}
data:
filename: /share/snapshots/cam1/{{states('input_text.snapshot_name_cam1_1')}}
target:
entity_id: camera.cam1_snapshots_clear
action: camera.snapshot
It’s a little bit of a botch, but I already have this up and running on the automation that emails the images, and it’s been doing OK for a couple of years. So I’ve not bothered to change it.
I’m currently using this code to add the file names and paths to an email
data:
images:
- >-
/share/snapshots/cam1/{{states('input_text.snapshot_name_cam1_1')}}
- >-
/share/snapshots/cam1/{{states('input_text.snapshot_name_cam1_2')}}
- >-
/share/snapshots/cam1/{{states('input_text.snapshot_name_cam1_3')}}
I thought that I could just use the exact same path in an image card on Lovelace to display the exact same image as I currently do in my email, but I’m obviously doing something wrong as it’s just showing a blank section like it can’t find the snapshot.
type: vertical-stack
cards:
- type: picture
image: >-
/share/snapshots/cam1/{{states('input_text.snapshot_name_cam1_1')}}
- type: picture
image: >-
/share/snapshots/cam1/{{states('input_text.snapshot_name_cam1_2')}}
- type: picture
image: >-
/share/snapshots/cam1/{{states('input_text.snapshot_name_cam1_3')}}
title: Snapshot
Am I formatting the path incorrectly, or is using a path that contains a helper state not possible with the image card.
I’ve tried the same thing with the frigate card and it’s given me the same problem.
Can anyone see where I’m going wrong?
I’m already successfully using this code to capture snapshots and email them to me, the images attach to the email perfectly, but using the same path the images don’t show up in Lovelace.