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?
It is:
homeassistant:
allowlist_external_dirs:
- /config/www/camera/
tom_l
September 10, 2020, 5:14pm
4
tom_l
September 10, 2020, 5:17pm
6
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
tom_l
September 10, 2020, 5:22pm
8
Probably because it is an invalid file name, read my workaround above.
Or use the Lovelace template custom card.
Lovelace Templates
I’ve gone and made a crazy card that allows you to pretty much template anything in Lovelace for your card configurations using any information available on the frontend; states, attributes, user, etc.
Want state/attribute-based icons? DONE!
Want dynamic stacks; vertical vs horizontal based on user? DONE!
Want OR conditionals? DONE!
The list is pretty much endless and I’m sure you all will come up with some crazy stuff. Be sure to share.
Go nuts! Enjoy!
Tried a simple name one, too.
I’ll try that
tom_l
September 10, 2020, 5:24pm
10
Hang on. If a simple name (no template) didn’t work then there may be a problem with your camera and the snapshot service.
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.