Show latest doorbell snapshot

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.)

1 Like

Make 2 photo

doorbell-yyyyMMddhhmm.jpg
doorbell.jpg

The timestamped is for archive and the doorbell.jpg is for display on dashboard

That’s not the issue. doorbell.jpg is there. But not picked up by the picture card. It keeps showing the ‘old’ image.

Use picture glance and try adding it as a camera

how to add it as a camera ? Why isn’t it loading the URL at every load? and even where does the image come from after the initial load from URL?

Tried markdown. That seems to work because it can load directly from the helper. Since that returns a unique name, it is not cached. No more need for copying also.

![Image](https://<myHome assistant URL>/local/snapshots/{{states("input_text.camera_driveway")}}) 
1 Like

Did you want current image or image at time bell rang?

I think your solution will be current image but may not show why bell rang. I ask to ensure you meet desired goal. In past I loaded current image but missed person and found this was not useful.

It does indeed not auto refresh, but as soon as the page is loaded it shows up the correct image. Since I do get a notification with the actial image, this is all sufficient.