Office 365 calendar -> DavMail -> hass CalDav

Hi,

I’ve made a working config where i use DavMail (open source) to my Office365 (without 2FA). DavMail is working both on Windows 10 and in Docker on the same host as hass.

With thinderbird i can connect to O365 with the following properties.

DavMail

 mode: O365 -> made it work on with Davmail on Windows 
  location properties file: C:\Users\User\.davmail.properties
  setting: davmail.allowRemote=true

Davmail docker:

sudo docker run --net=host --name davmail -e DAVMAIL_URL=<serveriphere> -v /home/docker/docker/davmail:/var/lib/davmail -v /home/docker/docker/davmail:/etc/davmail gzm55/davmail

Thunderbird

http://localip:1080/users/[email protected]/calendar

So, i’m pretty sure it is setup correctly.

Now i’m trying to get hass to connect with the CalDav component to davmail:
calendar:

i tried different configurations:

host.domain.eu:1080 
127.0.0.1 -> connects over port 80 
192.168.0.56:1080
127.0.0.1:1080

Does anyone managed to get this working or is willing to make this work? To me it seemed a nice idea.

Here some logging. The last attempt is without the portname and it doesnt make connection with a different error.

The first three attempts make connection to the host, but CalDav raises the “object has no attribute 'hostname”-error.

url: http://192.168.0.56:1080/users/[email protected]/calendar

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/objects.py", line 417, in calendars
    return self.calendar_home_set.calendars()
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 396, in calendar_home_set
    '{urn:ietf:params:xml:ns:caldav}calendar-home-set']
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 405, in calendar_home_set
    if (sanitized_url.hostname and
AttributeError: 'NoneType' object has no attribute 'hostname'

url: http://server.domain:1080/users/[email protected]/calendar

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/objects.py", line 417, in calendars
    return self.calendar_home_set.calendars()
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 396, in calendar_home_set
    '{urn:ietf:params:xml:ns:caldav}calendar-home-set']
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 405, in calendar_home_set
    if (sanitized_url.hostname and
AttributeError: 'NoneType' object has no attribute 'hostname'

url: http://127.0.0.1:1080/users/[email protected]/calendar

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/objects.py", line 417, in calendars
    return self.calendar_home_set.calendars()
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 396, in calendar_home_set
    '{urn:ietf:params:xml:ns:caldav}calendar-home-set']
  File "/usr/local/lib/python3.7/site-packages/caldav/objects.py", line 405, in calendar_home_set
    if (sanitized_url.hostname and
AttributeError: 'NoneType' object has no attribute 'hostname'

url: http://127.0.0.1/users/[email protected]/calendar

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: HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: /users/[email protected]/calendar/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc6ba2f2a10>: Failed to establish a new connection: [Errno 111] Connection refused'))