Home assistant connect to caldav

Hi,

I’m trying to connect my home assistant (hass.io) to nextcloud to get the calendars. But I have a connection error.

Error while setting up platform caldav
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 334, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fe5db1f1790>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='TLD.com', port=443): Max retries exceeded with url: /remote.php/dav/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fe5db1f1790>: Failed to establish a new connection: [Errno 111] Connection refused'))
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/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/caldav/calendar.py", line 74, in setup_platform
    calendars = client.principal().calendars()
  File "/usr/local/lib/python3.7/site-packages/caldav/davclient.py", line 118, in principal
    return Principal(self)
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 370, in __init__
    cup = self.get_properties([dav.CurrentUserPrincipal()])
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 219, in get_properties
    response = self._query_properties(props, depth)
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 129, in _query_properties
    return self._query(root, depth)
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 161, in _query
    url, body, depth)
  File "/usr/local/lib/python3.7/site-packages/caldav/davclient.py", line 133, in propfind
    {'Depth': str(depth)})
  File "/usr/local/lib/python3.7/site-packages/caldav/davclient.py", line 237, in request
    auth=auth, verify=self.ssl_verify_cert)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='TLD.com', port=443): Max retries exceeded with url: /remote.php/dav/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fe5db1f1790>: Failed to establish a new connection: [Errno 111] Connection refused'))

I think the problem comes from the fact that it is done directly via python without a web interface so it is not possible to make the web connection.

How can I do to perform this operation serenely.

thank you for your help.

Unfortunately you decided to totally ignore the issue template and haven’t provided any valuable information about your environment, the used software, how you try to access the server, etc., etc. This makes it impossible to giving any advise.

Additionally you’re asking the question in the Nextcloud forum and not in the hass.io forum, which most likely would be able to provide a better support for its own piece of software.

Sorry for the lack of precision, I thought the simple part would help to solve the problem.

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='TLD.com', port=443): Max retries exceeded with url: /remote.php/dav/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fe5db1f1790>: Failed to establish a new connection: [Errno 111] Connection refused'))

I’m using nextcloud 17.0.2 on a debian 10 in a virtualized environment. It works with a sub-domain, so it is behind a nginx proxy that redirects the nextcloud request set to this server. if you need more information, just tell me.

I’ve dont log in logging nextcloud, in nginx don’t have log significant for this error.

I think the problem is that the authentication doesn’t work because the connection is not registered in the nextcloud sessions. I would like to know how to make it register without needing to have the web login window, like any connection other than from a web browser.

This problem doesn’t raise hass.io because this module works with other caldavs without any problem.

This topic was automatically closed 108 days after the last reply. New replies are no longer allowed.