Camera snapshot entity_id in filename

I’m getting the same warnings, at first I just placed {{ entity_id }} without anything else, but then i got the same warning again…

But how to handle actions with multiple entities. Do we need to create an action for every camera?
I tried entity_id as in the documentation Camera - Home Assistant, entity_id.entity_id and entity_id.name, all throw the error through spook.

Have you find a solution for this error? because on the official Home Assistant instructions it even says to use {{ entity_id }}

Well, no, but the cause: Camera.record service not working with entity_id.name in template, says entity_id is undefined · Issue #40241 · home-assistant/core · GitHub and see the commit below: Deprecate entity_id template variable in camera services by emontnemery · Pull Request #128592 · home-assistant/core · GitHub

I tried to find hints how I could do this with a variable but how do I step through them?
In the end I filed a bug, maybe add your thumbs there to gain a bit more attraction:

The docs are uptated, above the variable is in the example defined first and then used in the camera.record action:

actions:
  - variables:
      entity_id: camera.yourcamera  # Store the camera entity_id in a variable for reuse

I’m not sure I read this correctly, but if I do, the documentation is very misleading:
My understanding: entity_id in variables, is just a variable with a poor choice of name being the same as the argument “entity_id” of the service snapshot. So the {{ entity_id }} in the filename, is not the snapshot argument, but the user defined variable above.
Can someone test this by changing the name of that variable and see if it works the same in the automation?

In any case, I managed to fix my own problem in Node Red by changing

{"filename":"/config/www/tmp/snapshot_{{ entity_id.entity_id }}.jpg"}

to

{"filename":"/config/www/tmp/snapshot_"&msg.camera_entity&".jpg"}

Where msg.camera_entity is the name of my camera, passed in the msg in node red (in my case, it’s defined in the previous node). The point is to have a generic snapshot+notification flow, for multiple cameras.

You can name the variable whatever you want.

Thanks for the reply. Do you know how to suggest editing the documentation? If an admin reads us :eyes:

Every page has a link to GitHub to edit it.

Thanks, proposed a pull request for it

1 Like