Save camera snapshot in file with timestamp and send the file to email with the filename as a variable

Hi All

I’ve been searching for hours and days to get my camera snapshots working, without lots of success.

So I write my first question in this forum and hope to get help.

What I want to do:

  • Save camera snapshots in files with timestamp in Home Asssistant. This is done. It works!

Not yet found a solution:

  • Save the filename in a variable
  • Display a notification in the Home Assistant UI with the filename
  • Send the snapshot to email recipient with the content of the filename variable.
  • For a first step I tried to just save a filename in a variable and use this variable
    in the code (Next step would be to use the variable filename produced at snapshot
    time. I also tried this but without success)

State of my automation:

I can save the snapshots in files with timestamps
I can send snapshots with fixed filenames to email

My problems at time

Part 1: Display a notification iin the HA UI

This is my code in the automation:

- id: '1719961824343'
  alias: Cam4 Action
  description: Cam4 Action
  trigger:
  - type: motion
    platform: device
    device_id: 8753bb34da42996213ef21c146aee6d6
    entity_id: 0f4adb02bebd29066e7bbc0eb4f3ec69
    domain: binary_sensor
  condition: []
  action:
  - variables:
      snapshot_filename:
        value: '/media/Snapshots/Cam4/cam4_snapshot1_2024_7_4_0_9.jpg'
  - service: notify.persistent_notification
    data:
      message: snapshot_filename
      title: Cam Benachrichtigung
      data: snapshot_filename

Error:
[139714527867616] Error handling message: expected dict for dictionary value @ data[‘data’]. Got None (invalid_format) Boebes from 192.168.178.33 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0)

Part 2:

Send email with snapshot in filename variable:

  - service: notify.email_snapshot
    metadata: {}
    data:
      message: Cam_snapshot
      title: Cam_snapshot
      target: name@mailprovider
      data:
        images:
        -  snapshot_filename

Error: remote_path_not_allowed

Logger: homeassistant.components.websocket_api.http.connection
Quelle: components/websocket_api/commands.py:797
Integration: Home Assistant WebSocket API (Dokumentation, Probleme)
Erstmals aufgetreten: 12:32:40 (1 Vorkommnisse)
Zuletzt protokolliert: 12:32:40

[139714527867616] remote_path_not_allowed

It would be great if someone could help me with detailed code, how to solve the problems. Thanks