ONVIF again

Hello!

Need help with this issue on raspberry pi 4 with Home Assistant 0.104.0.dev20191214 version

With this setting camera work correctly, but need PTZ

With this setting have error in log:

  • platform: onvif
    host: 192.168.1.54
    username: admin
    password: 653456w
    port: 8001
    name: Cam1

log error:

2019-12-14 12:15:20 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/onvif/client.py", line 26, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/onvif/client.py", line 102, in __init__
    transport = AsyncTransport(None) if no_cache else AsyncTransport(None, cache=SqliteCache())
  File "/usr/local/lib/python3.7/site-packages/zeep/cache.py", line 80, in __init__
    self._db_path = path if path else _get_default_cache_path()
  File "/usr/local/lib/python3.7/site-packages/zeep/cache.py", line 160, in _get_default_cache_path
    os.makedirs(path)
  File "/usr/local/lib/python3.7/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/src/homeassistant/homeassistant/components/onvif/camera.py", line 118, in async_setup_platform
    await hass_camera.async_initialize()
  File "/usr/src/homeassistant/homeassistant/components/onvif/camera.py", line 166, in async_initialize
    await self._camera.update_xaddrs()
  File "/usr/local/lib/python3.7/site-packages/onvif/client.py", line 222, in update_xaddrs
    self.devicemgmt  = self.create_devicemgmt_service()
  File "/usr/local/lib/python3.7/site-packages/onvif/client.py", line 334, in create_devicemgmt_service
    return self.create_onvif_service('devicemgmt', from_template)
  File "/usr/local/lib/python3.7/site-packages/onvif/client.py", line 322, in create_onvif_service
    transport=self.transport)
  File "/usr/local/lib/python3.7/site-packages/onvif/client.py", line 29, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: [Errno 13] Permission denied: '/.cache'

Did you managed to fix the issue. I am having the same problem.

[Update 23.03.2020]
I have solved the problem for me. The activation of ONVIF causes Home Assistant to download zeep, but it doesn’t work because /.cache belongs to the root user, it is located under /.

For me, Hass runs in the docker as non-root, hence the problem. So I simply linked /.cache to the home directory of my Hass user and it works.
[/Update]