I have a camera mounted near my front door. When someOne rings the doorbell, A snapshot will be made and can be notified to me. Fine so far. But now I want to add a small picture of the latest snapshot in my dashboard. like this:
I used a stack in card with an image card. like this:
type: custom:vertical-stack-in-card
cards:
- type: entities
show_header_toggle: false
state_color: true
entities:
- entity: switch.doorbell
type: custom:multiple-entity-row
name: Deurbel
secondary_info: last-changed
icon: mdi:bell
show_state: false
tap_action:
action: more-info
state_color: true
- type: picture
image: https:<my home assistant url>/local/snapshots/doorbell.jpg
- type: entities
show_header_toggle: false
state_color: true
entities:
- entity: sensor.placeholder
name: " "
show_state: false
icon: mdi:blanc
type: custom:multiple-entity-row
entities:
- entity: input_boolean.doorbell_photo
name: foto
icon: mdi:camera
state_color: true
tap_action:
action: toggle
- entity: automation.deurbel_notificatie
name: notificatie
icon: mdi:message-alert-outline
state_color: true
tap_action:
action: toggle
An automation does the magic like this:
automation:
- id: doorbell_notification
alias: Deurbel notificatie
description: send notification when someone rings the doorbell
triggers:
- trigger: state
entity_id: switch.doorbell
to: 'on'
conditions:
- condition: template
value_template: '{{states("input_boolean.doorbell_photo")=="on"}}'
actions:
- action: input_text.set_value
target:
entity_id: input_text.camera_driveway
data:
value: '{{now().strftime("%m%d-%-H%M")}}doorbell.jpg'
- action: camera.snapshot
data:
filename: '/config/www/snapshots/{{states("input_text.camera_driveway")}}'
target:
entity_id: camera.mycamera_channel1_substream1
- delay:
seconds: 1
- action: script.turn_on
entity_id: script.notify
data:
variables:
title: 'Deurbel'
message: 'Iemand heeft aangebeld om {{ now().strftime("%-H:%M (%-d/%-m)")}}'
image: '{{states("input_text.camera_driveway")}}'
urgent: true
- action: shell_command.copy_latest_doorbell_capture
- delay:
minutes: 2
mode: single
As you can see, the script will create a filename for the snapshot based on time and store it in a helper (input_text.camera_driveway), so the notification script will pick up the correct filename. Since this helper contains the name of the latest snapshot image, it should be possible to use it for displaying on the dashboard. However, the picture entiy can not make use of the value in the helper, not can it use jninja, so it refers to a fixed name (doorbell.jpg) and the script copies the file to this fixed name using a commandline copy. That works okay.
There’s only one major problem: It seems that the picture entity does not refresh the image!
Anybody a suggestion?
If possible I like to use a much smaller image that is more incorporated into the card (I hate having seperate cards for every entity, so I mostly use entities grouped on a card.)