So I have post in the “Developer tools” section in “Services” to test if the camera will record and I get the error Failed to call service camera.record. Error rendering data template: UndefinedError: 'entity_id' is undefined
I get this error Failed to call service camera.record. template value should be a string for dictionary value @ data['sequence'][0]['data']. Got {'duration': 30, 'lookback': 0, 'filename': '/tmp/{{ state_attr(entity_id, \'computer_camera\' }}_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4'}
with this {{ state_attr(entity_id, 'name' }}
When I load with the example data in HA, it fills in this filename: /tmp/snapshot_{{ entity_id.name }}.mp4
camera.video_doorbell_clear isn’t a variable. It is an entity_id and must be put in quotes, that is how the state_attr() function requires its arguments.
Variables must not be quoted or they become just the variable name as a string, rather than the contents of the variable.
Try this in the template editor:
{% set 'foobar' = 'camera.video_doorbell_clear' %}
{{ state_att(foobar,'friendly_name') }}
That will work because the variable foobar resolves to an entity id in the state_attr() function.
Now try this:
{% set 'foobar' = 'camera.video_doorbell_clear' %}
{{ state_att('foobar','friendly_name') }}
This does not work because you are using the actual string 'foobar' in the state_attr() function, strings don’t resolve to their contenst like variables do.
So then it appears that the camera.record service is not recognising entity_id as a variable (despite the documentation) as the following call returns the error message:
Failed to call service camera.record. Error rendering data template: UndefinedError: ‘entity_id’ is undefined