Service camera.record and permissions in hass.io

Hi. I try to configure service camera.record in hass.io but with no luck. How to set permissions for folders in /share? When I try to start this:
{
“entity_id”: “camera.wejscie”,
“filename”:"/share/test.mp4"
}

I got this:
homeassistant.exceptions.HomeAssistantError: Can’t write /share/record/1.mp4, no access to path!

And bonus question - does hass have some type of motion detection for cameras? I have two onvif cameras and one generic camera.

1 Like

Following. I have the same problem

Same problem for me.
After changing to
“filename”:"/tmp/test.mp4" I get other errors like: “Stream already recording” but it is not true: There is no camera recording at all.
Thought to install ffmpeg on my rpi to fix it, but the only effect is that my camera is not showing the stream any more in HA, so I uninstalled it again.
Also added /tmp as whitelisted external dir in the config, but no success at all.
Any hints to fix this are welcome!

1 Like

I have a similar error

Ok guys, I found solution. After adding directory to whitelisted you need to reboot machine with hass.io, not only hass. Worked for me with /share folder

Yeah, I did that to get rid of the “can’t write” error. Now I got this:
Apr 09 22:17:11 pi hass[25123]: Exception in thread stream_worker:
Apr 09 22:17:11 pi hass[25123]: Traceback (most recent call last):
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/threading.py”, line 914, in _bootstrap_inner
Apr 09 22:17:11 pi hass[25123]: self.run()
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/threading.py”, line 862, in run
Apr 09 22:17:11 pi hass[25123]: self._target(*self._args, **self._kwargs)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/worker.py”, line 52, in stream_worker
Apr 09 22:17:11 pi hass[25123]: import av
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/av/init.py”, line 9, in
Apr 09 22:17:11 pi hass[25123]: from av._core import time_base, pyav_version as version
Apr 09 22:17:11 pi hass[25123]: ImportError: libavdevice.so.57: cannot open shared object file: No such file or directory
Apr 09 22:17:11 pi hass[25123]: 2019-04-09 22:17:11 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1715446192] Stream already recording to /tmp/test.mp4!
Apr 09 22:17:11 pi hass[25123]: Traceback (most recent call last):
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api/commands.py”, line 122, in handle_call_service
Apr 09 22:17:11 pi hass[25123]: connection.context(msg))
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1138, in async_call
Apr 09 22:17:11 pi hass[25123]: self._execute_service(handler, service_call))
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
Apr 09 22:17:11 pi hass[25123]: yield self # This tells Task to wait for completion.
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
Apr 09 22:17:11 pi hass[25123]: future.result()
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
Apr 09 22:17:11 pi hass[25123]: raise self._exception
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
Apr 09 22:17:11 pi hass[25123]: result = coro.send(None)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1160, in _execute_service
Apr 09 22:17:11 pi hass[25123]: await handler.func(service_call)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 188, in handle_service
Apr 09 22:17:11 pi hass[25123]: self._platforms.values(), func, call, service_name
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py”, line 314, in entity_service_call
Apr 09 22:17:11 pi hass[25123]: future.result() # pop exception if have
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
Apr 09 22:17:11 pi hass[25123]: raise self._exception
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 241, in _step
Apr 09 22:17:11 pi hass[25123]: result = coro.throw(exc)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py”, line 330, in _handle_service_platform_call
Apr 09 22:17:11 pi hass[25123]: await func(entity, data)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/camera/init.py”, line 677, in async_handle_record_service
Apr 09 22:17:11 pi hass[25123]: blocking=True, context=call.context)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1138, in async_call
Apr 09 22:17:11 pi hass[25123]: self._execute_service(handler, service_call))
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
Apr 09 22:17:11 pi hass[25123]: yield self # This tells Task to wait for completion.
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
Apr 09 22:17:11 pi hass[25123]: future.result()
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
Apr 09 22:17:11 pi hass[25123]: raise self._exception
Apr 09 22:17:11 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
Apr 09 22:17:11 pi hass[25123]: result = coro.send(None)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1160, in _execute_service
Apr 09 22:17:11 pi hass[25123]: await handler.func(service_call)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/init.py”, line 114, in async_record
Apr 09 22:17:11 pi hass[25123]: await async_handle_record_service(hass, call)
Apr 09 22:17:11 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/init.py”, line 217, in async_handle_record_service
Apr 09 22:17:11 pi hass[25123]: .format(recorder.video_path))
Apr 09 22:17:11 pi hass[25123]: homeassistant.exceptions.HomeAssistantError: Stream already recording to /tmp/test.mp4!
Apr 09 22:17:14 pi hass[25123]: 2019-04-09 22:17:14 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1715446192] Stream already recording to /tmp/test.mp4!
Apr 09 22:17:14 pi hass[25123]: Traceback (most recent call last):
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api/commands.py”, line 122, in handle_call_service
Apr 09 22:17:14 pi hass[25123]: connection.context(msg))
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1138, in async_call
Apr 09 22:17:14 pi hass[25123]: self._execute_service(handler, service_call))
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
Apr 09 22:17:14 pi hass[25123]: yield self # This tells Task to wait for completion.
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
Apr 09 22:17:14 pi hass[25123]: future.result()
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
Apr 09 22:17:14 pi hass[25123]: raise self._exception
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
Apr 09 22:17:14 pi hass[25123]: result = coro.send(None)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1160, in _execute_service
Apr 09 22:17:14 pi hass[25123]: await handler.func(service_call)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 188, in handle_service
Apr 09 22:17:14 pi hass[25123]: self._platforms.values(), func, call, service_name
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py”, line 314, in entity_service_call
Apr 09 22:17:14 pi hass[25123]: future.result() # pop exception if have
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
Apr 09 22:17:14 pi hass[25123]: raise self._exception
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 241, in _step
Apr 09 22:17:14 pi hass[25123]: result = coro.throw(exc)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py”, line 330, in _handle_service_platform_call
Apr 09 22:17:14 pi hass[25123]: await func(entity, data)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/camera/init.py”, line 677, in async_handle_record_service
Apr 09 22:17:14 pi hass[25123]: blocking=True, context=call.context)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1138, in async_call
Apr 09 22:17:14 pi hass[25123]: self._execute_service(handler, service_call))
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
Apr 09 22:17:14 pi hass[25123]: yield self # This tells Task to wait for completion.
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
Apr 09 22:17:14 pi hass[25123]: future.result()
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
Apr 09 22:17:14 pi hass[25123]: raise self._exception
Apr 09 22:17:14 pi hass[25123]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
Apr 09 22:17:14 pi hass[25123]: result = coro.send(None)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1160, in _execute_service
Apr 09 22:17:14 pi hass[25123]: await handler.func(service_call)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/init.py”, line 114, in async_record
Apr 09 22:17:14 pi hass[25123]: await async_handle_record_service(hass, call)
Apr 09 22:17:14 pi hass[25123]: File “/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/init.py”, line 217, in async_handle_record_service
Apr 09 22:17:14 pi hass[25123]: .format(recorder.video_path))
Apr 09 22:17:14 pi hass[25123]: homeassistant.exceptions.HomeAssistantError: Stream already recording to /tmp/test.mp4!

And after installing ffmpeg:

Exception in thread stream_worker:
Apr 09 22:31:27 pi hass[9343]: Traceback (most recent call last):
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
Apr 09 22:31:27 pi hass[9343]:     self.run()
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/threading.py", line 862, in run
Apr 09 22:31:27 pi hass[9343]:     self._target(*self._args, **self._kwargs)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/worker.py", line 53, in stream_worker
Apr 09 22:31:27 pi hass[9343]:     container = av.open(stream.source, options=stream.options)
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 275, in av.container.core.open
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 227, in av.container.core.Container.__cinit__
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 129, in av.container.core.ContainerProxy.__init__
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 195, in av.container.core.ContainerProxy.err_check
Apr 09 22:31:27 pi hass[9343]:   File "av/utils.pyx", line 105, in av.utils.err_check
Apr 09 22:31:27 pi hass[9343]: av.AVError: [Errno 808465656] Server returned 400 Bad Request: 'rtsp://ipcam:554'
Apr 09 22:31:27 pi hass[9343]: Exception in thread stream_worker:
Apr 09 22:31:27 pi hass[9343]: Traceback (most recent call last):
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
Apr 09 22:31:27 pi hass[9343]:     self.run()
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/threading.py", line 862, in run
Apr 09 22:31:27 pi hass[9343]:     self._target(*self._args, **self._kwargs)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/worker.py", line 53, in stream_worker
Apr 09 22:31:27 pi hass[9343]:     container = av.open(stream.source, options=stream.options)
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 275, in av.container.core.open
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 227, in av.container.core.Container.__cinit__
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 129, in av.container.core.ContainerProxy.__init__
Apr 09 22:31:27 pi hass[9343]:   File "av/container/core.pyx", line 195, in av.container.core.ContainerProxy.err_check
Apr 09 22:31:27 pi hass[9343]:   File "av/utils.pyx", line 105, in av.utils.err_check
Apr 09 22:31:27 pi hass[9343]: av.AVError: [Errno 808465656] Server returned 400 Bad Request: 'rtsp://ipcam:554'
Apr 09 22:31:27 pi hass[9343]: 2019-04-09 22:31:27 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1754265008] Stream already recording to /tmp/test.mp4!
Apr 09 22:31:27 pi hass[9343]: Traceback (most recent call last):
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api/commands.py", line 122, in handle_call_service
Apr 09 22:31:27 pi hass[9343]:     connection.context(msg))
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1138, in async_call
Apr 09 22:31:27 pi hass[9343]:     self._execute_service(handler, service_call))
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
Apr 09 22:31:27 pi hass[9343]:     yield self  # This tells Task to wait for completion.
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
Apr 09 22:31:27 pi hass[9343]:     future.result()
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
Apr 09 22:31:27 pi hass[9343]:     raise self._exception
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
Apr 09 22:31:27 pi hass[9343]:     result = coro.send(None)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1160, in _execute_service
Apr 09 22:31:27 pi hass[9343]:     await handler.func(service_call)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
Apr 09 22:31:27 pi hass[9343]:     self._platforms.values(), func, call, service_name
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 314, in entity_service_call
Apr 09 22:31:27 pi hass[9343]:     future.result()  # pop exception if have
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
Apr 09 22:31:27 pi hass[9343]:     raise self._exception
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
Apr 09 22:31:27 pi hass[9343]:     result = coro.throw(exc)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 330, in _handle_service_platform_call
Apr 09 22:31:27 pi hass[9343]:     await func(entity, data)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/camera/__init__.py", line 677, in async_handle_record_service
Apr 09 22:31:27 pi hass[9343]:     blocking=True, context=call.context)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1138, in async_call
Apr 09 22:31:27 pi hass[9343]:     self._execute_service(handler, service_call))
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
Apr 09 22:31:27 pi hass[9343]:     yield self  # This tells Task to wait for completion.
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
Apr 09 22:31:27 pi hass[9343]:     future.result()
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
Apr 09 22:31:27 pi hass[9343]:     raise self._exception
Apr 09 22:31:27 pi hass[9343]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
Apr 09 22:31:27 pi hass[9343]:     result = coro.send(None)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1160, in _execute_service
Apr 09 22:31:27 pi hass[9343]:     await handler.func(service_call)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/__init__.py", line 114, in async_record
Apr 09 22:31:27 pi hass[9343]:     await async_handle_record_service(hass, call)
Apr 09 22:31:27 pi hass[9343]:   File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/stream/__init__.py", line 217, in async_handle_record_service
Apr 09 22:31:27 pi hass[9343]:     .format(recorder.video_path))
Apr 09 22:31:27 pi hass[9343]: homeassistant.exceptions.HomeAssistantError: Stream already recording to /tmp/test.mp4!

This is interesting: https://github.com/home-assistant/home-assistant/issues/20668