Service camera.snapshot fails after 0.115 upgrade

Guys my HA won’t now pull a camera.snapshot from any of my three IP cameras. Two are using the generic platform and one the Amrcest platform. All worked fine on HA 0.114.

Tried using the developer tools to hand launch a snapshot but it ‘fails to call service’ with ‘camera undefined’ as the error type.
My cameras still have the same names as they did before and I can view their picture cards as normal.
Any clues ? Did service call syntax get changed in 0.115 ?

LOG

Logger: homeassistant.components.websocket_api.http.connection.1777376128
Source: helpers/template.py:287
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 9:54:48 PM (10 occurrences)
Last logged: 10:09:05 PM

UndefinedError: 'camera' is undefined
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 285, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'camera' is undefined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 137, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1315, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1350, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 459, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 655, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 490, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 653, in async_handle_snapshot_service
    snapshot_file = filename.async_render(variables={ATTR_ENTITY_ID: camera})
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 287, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'camera' is undefined

Additionally, I’ve updated to 0.115.1 and also done a full power cycle. Problem remains…

I’ve spent a few hours trying to see why this broke for me after 0.115.
I still don’t know why, but I found a workaround.

To make my old automations with camera.snapshot service calls work I have had to ditch the templates with entity_id. and direct specify the filename:

This fails (but worked for me for fine with 0.114)

data:
  filename: '/share/ipcamera/snapshot_{{ entity_id.entity_id }}.jpg'
entity_id: camera.dahua_camera
service: camera.snapshot

This works in 0.115

service: camera.snapshot
data:
  filename: /share/ipcamera/snapshot_dahua_camera.jpg
entity_id: camera.dahua_camera
1 Like

Thanks for this! I now use this workaround with ffmpeg: instead of the generic IP camera so that I don’t get the entity_id error.