Unable to setup Caldav

Hi All,

Saw in the latest release that caldav support was added so I thought I’d give it a whirl as I’ve been using a Caldav server with Mozilla Thunderbird as a client for a number of years. So far I have’t had any luck getting it to work by following the guide here: https://home-assistant.io/components/calendar.caldav/

Here’s the relevant bits from my log:
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: #033[31m2017-12-18 15:24:51 ERROR (MainThread) [homeassistant.components.calendar] Error while setting up platform caldav#033[0m
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: Traceback (most recent call last):
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/srv/hass/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 171, in _async_setup_platform
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 400, in wait_for
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: return fut.result()
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: raise self._exception
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: result = self.fn(*self.args, **self.kwargs)
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/srv/hass/lib/python3.5/site-packages/homeassistant/components/calendar/caldav.py”, line 59, in setup_platform
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: config.get(CONF_PASSWORD))
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/srv/hass/lib/python3.5/site-packages/caldav/davclient.py”, line 93, in init
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: if self.url.username is not None:
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/srv/hass/lib/python3.5/site-packages/caldav/lib/url.py”, line 91, in getattr
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: self.url_parsed = urlparse(self.url_raw)
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/usr/lib/python3.5/urllib/parse.py”, line 295, in urlparse
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: url, scheme, _coerce_result = _coerce_args(url, scheme)
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/usr/lib/python3.5/urllib/parse.py”, line 115, in _coerce_args
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: return _decode_args(args) + (_encode_result,)
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/usr/lib/python3.5/urllib/parse.py”, line 99, in _decode_args
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: return tuple(x.decode(encoding, errors) if x else ‘’ for x in args)
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: File “/usr/lib/python3.5/urllib/parse.py”, line 99, in
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: return tuple(x.decode(encoding, errors) if x else ‘’ for x in args)
Dec 18 15:24:51 ca-vic-cm-hass01 hass[17317]: AttributeError: ‘function’ object has no attribute ‘decode’#033[0m

and my config file:
calendar:

  • platform: caldav
    url: http://< servername >:1080/users/< username >/calendar
    username: < username >
    password: < password >

really appreciate any suggestions.
Cheers!

Probably not the problem, but you don’t specify a host in your URL, just a port number (1080).

Sorry, I pulled the hostname, username and password out of the config to sanitize it, they way I had formatted them the website didn’t display. I do have them present in the actual config.

Thanks for catching that though, edited the post for clarity.

This is a known problem that will be fixed in 0.60.1

OK cool! Thanks for the note. I’ll wait for the 0.60.1 release.

Cheers!

I’ve updated to the 0.61 release but am still having issues with CalDav. The following is my error log (using same config as before):

Error while setting up platform caldav

Traceback (most recent call last):
   File "/srv/hass/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 171, in _ async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
 File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
return fut.result()
 File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
 File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
 File "/srv/hass/lib/python3.5/site-packages/homeassistant/components/calendar/caldav.py", line 62, in setup_platform
calendars = client.principal().calendars()
 File "/srv/hass/lib/python3.5/site-packages/caldav/objects.py", line 354, in calendars
return self.calendar_home_set.calendars()
 File "/srv/hass/lib/python3.5/site-packages/caldav/objects.py", line 336, in calendar_home_set
self.calendar_home_set = chs['{urn:ietf:params:xml:ns:caldav}calendar-home-set']
 File "/srv/hass/lib/python3.5/site-packages/caldav/objects.py", line 345, in calendar_home_set
if sanitized_url.hostname and sanitized_url.hostname != self.client.url.hostname:

AttributeError: ‘NoneType’ object has no attribute ‘hostname’

Its working fine for me. It looks like its failing on the hostname. Do you still have that port in the url?

Thanks for the reply, I do still have the port, is there a better way of specifying a non-default port?

I just tried adding a port number to my url, and it didn’t complain, which rules that out as the problem. I’m not sure what else to try.

The only thing different in my configuration is that I have a list of 1 calendar. It is supposed to be optional, but that could be a mistake

calendar:
  - platform: caldav
    url: !secret owndrive_url
    username: !secret owndrive_username
    password: !secret owndrive_password
    calendars:
      - Waste