Error on taking camera snapshot

When calling the camera snapshot service I am getting the error: required key not provided @ data[‘filename’]"

This is my picture entity configuration:

aspect_ratio: 0%
camera_view: live
entity: camera.kamera
show_name: false
show_state: false
type: picture-entity
hold_action:
  action: call-service
  service: camera.snapshot
  data:
    entity_id: camera.kamera
    filename: '/config/www/camera/kamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'

So, I do not understand why this error occurs.
If I call the service under the dev tools it is working, but the jpg is empty (only a fow bytes) .
Any ideas on both issues?

The path part of filename must be an entry in the allowlist_external_dirs in your homeassistant: section of your configuration.yaml file.

Camera - Home Assistant

It is:

homeassistant:
  allowlist_external_dirs:
    - /config/www/camera/

Try service_data instead of data.

https://www.home-assistant.io/lovelace/actions/#service_data

Same error

data_template

Actually never mind. You can’t template there. Just realised this is in Lovelace. Try a name without a template, it should work.

The way around it is to put your snapshot service in a script (using data_template) and call the script from the hold action.

Sorry, typo: service-data instead of service_data.
Error is gone, but no file at the given location

Probably because it is an invalid file name, read my workaround above.

Or use the Lovelace template custom card.

Tried a simple name one, too.

I’ll try that

Hang on. If a simple name (no template) didn’t work then there may be a problem with your camera and the snapshot service.

Thank you anyway.

I changed my camera configuration to:

camera:
  - platform: ffmpeg
    name: Kamera
    input: rtsp://xxx:[email protected]:554/live/ch0

and created an automation task that calls the camera.snapshot service every day at 13:30 to save at filename: ‘/config/www/camera/kamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg’

This works and this is all I wanted.

A tap or hold action in my picture-entity that is calling the same still won’t save the snapshot. Maybe some other bug.