iCloud Calendar integration

I’m struggling a bit with this integration. I followed the instructions linked above and got the “magic URL” to a shared, private iCloud calendar that we’ll call “Automated Family.” Added the following config with and without a calendars block:

calendar:
  - platform: caldav
    username: !secret icloud_login
    password: !secret icloud_password
    url: !secret icloud_url

I fat-fingered the URL initially and got an error in the log, so it seems to be picking up the config. After fixing the URL, there are no errors in the log, but also no calendar entities. I also searched for variations of cal, dav, and “Automated Family” in the entities list to no avail, and the “Calendar” tab doesn’t show anything (not sure if it should or not).

There aren’t many recent updates to this thread, so not sure the problem is the fact that this is a shared iCloud calendar between my wife and I, or something has gone wrong on the HA or iCloud side. Any help would be appreciated as my goal is to get our “family calendar” displayed somewhere so that the kids can see it and see their weekly activities vs. writing them on the chalkboard every week. A successful execution likely makes the case for an e-Ink display project as well :slight_smile:

Thanks!

perhaps you could try this url field: url: https://caldav.icloud.com

YES!!! Much like T.S. Eliot I have done a grand exploration only to arrive where I started and know the place for the first time. Changing the URL and ignoring all the fancy curl action above works perfectly!

1 Like

Hi! I’m trying to add my calendar but iy seems i’m missing something.

Here is my conf:

#calendrier icloud
calendar:
  - platform: caldav
    username: my apple id
    password: my apple pass
    url: webcal://p31-caldav.icloud.com/published/2/lotsOfCharacters

And the log:

Logger: homeassistant.components.calendar
Source: components/caldav/calendar.py:77
Integration: Calendrier (documentation, issues)
First occurred: 16:12:43 (1 occurrences)
Last logged: 16:12:43

Error while setting up caldav platform for calendar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/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 77, in setup_platform
    calendars = client.principal().calendars()
  File "/usr/local/lib/python3.8/site-packages/caldav/davclient.py", line 124, in principal
    return Principal(self)
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 381, in __init__
    cup = self.get_properties([dav.CurrentUserPrincipal()])
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 227, in get_properties
    response = self._query_properties(props, depth)
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 130, in _query_properties
    return self._query(root, depth)
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 164, in _query
    ret = getattr(self.client, query_method)(
  File "/usr/local/lib/python3.8/site-packages/caldav/davclient.py", line 138, in propfind
    return self.request(url or self.url, "PROPFIND", props,
  File "/usr/local/lib/python3.8/site-packages/caldav/davclient.py", line 250, in request
    r = requests.request(method, url, data=to_wire(body),
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 649, in send
    adapter = self.get_adapter(url=request.url)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 742, in get_adapter
    raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for 'webcal://p31-caldav.icloud.com/published/2/LotdsOfCharacters/'

I’ve tried with url https://caldav.icloud.com/published/2/lotsofcharacters with no luck:

Logger: homeassistant.components.calendar
Source: components/caldav/calendar.py:77
Integration: Calendrier (documentation, issues)
First occurred: 16:21:57 (1 occurrences)
Last logged: 16:21:57

Error while setting up caldav platform for calendar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/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 77, in setup_platform
    calendars = client.principal().calendars()
  File "/usr/local/lib/python3.8/site-packages/caldav/davclient.py", line 124, in principal
    return Principal(self)
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 381, in __init__
    cup = self.get_properties([dav.CurrentUserPrincipal()])
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 227, in get_properties
    response = self._query_properties(props, depth)
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 130, in _query_properties
    return self._query(root, depth)
  File "/usr/local/lib/python3.8/site-packages/caldav/objects.py", line 164, in _query
    ret = getattr(self.client, query_method)(
  File "/usr/local/lib/python3.8/site-packages/caldav/davclient.py", line 138, in propfind
    return self.request(url or self.url, "PROPFIND", props,
  File "/usr/local/lib/python3.8/site-packages/caldav/davclient.py", line 277, in request
    raise ex
caldav.lib.error.AuthorizationError: AuthorizationError at 'https://caldav.icloud.com/published/2/lotsofcharacters', reason 'Unauthorized'

Nevermind, i’ve managed to make it work!

Here is the correct config:

#calendrier icloud
calendar:
  - platform: caldav
    username: apple id
    password: generated with appleid.apple.com
    url: https://caldav.icloud.com
    calendars:
      - test

The name of the calendars has to be the same that icloud’s.

I’m having the same problem with the Entity ID calendar.family already exists Error. Did you found a solution to the problem?

1 Like

Can I also use a public Icloud calender (click on a calender in the calender app and acticate “public calender”) without username or password?

The url is: webcal://p69-caldav.icloud.com/published/2/xxxxxxxxxxx

Is this still worth trying?

I never got it to work. :frowning:

hmmm - have put this is my config and it doesn’t generate any errors - just nothing shows. So no errors but no sensors/calendars either.

1 Like

Turns out, as with some much in IT, it was a capitalisation issue on the calendar in question.

Now wondering - as the HA integration only seems to load one event at a time, what happens if you have overlapping or all day events? I tried to create a custom ‘search’ calendar but it nuked my ‘all events’ calendar, annoyingly.

Please note that if you use the custom_calendars option, only those calendars will be loaded. You cannot use calendars and custom_calendars in the same configuration.

Ok, I guess it’s my turn. I’ve looked everywhere and can’t get this to work.
I used this is my config:

calendar:
  - platform: caldav
    username: !secret iclouduser
    password: !secret icloudcalpwd
    url: https://caldav.icloud.com
    calendars:
      - 'Family'
      - 'Home'
      - 'Work'
      - 'Birthdays'

Worked originally, no problem. Then it stopped updating. Tried resetting the app-password, no joy.
Tried updating the calendar names with lower case names. They all disappeared from my calendar (so they were correct before). Changed them back and Calendar items came back, but still no update.
To be clear, I have items on my work calendar for today on my iphone, but they don’t show up in the Home Assistant Calendar. But, there are old item from the work calendar from two weeks ago that are still there, meaning I know it worked at one time.

Any help would be appreciated :slight_smile:

Sorry, one last thing. Nothing shows up in any of the logs.

Try without secrets. I couldn’t get secrets to work with my iCloud calendar.

@eximo84 I tried without secret and I got it working though it loads only one calendar from the configuration I provided. Only the ‘Family’ one. Any idea how to make it load both? My configuration below:

# iCalendar
- platform: caldav
  username: [email protected]
  password: xxx-xxx-xxx-xxx
  url: https://caldav.icloud.com
  calendars:
    - 'Personal'
    - 'Family'

Read the documentation for caldav for icloud and I learned that one does not have to declare the caledars in the configuration. They will be found automatically.

So you just need this in configuration.yaml:

# Example configuration.yaml entry for iCloud, calendars will be found automatically
calendar:
  - platform: caldav
    username: !secret userIcloud
    password: !secret passIcloud
    url: https://caldav.icloud.com

I’m not able to get this to work. I worked normally earlier, but I guess in one of the recent updates it stopped working. I tried using my login credentials directly in config instead of !secret, but that didn’t help. Anyone got any ideas? Here is the error I get:

Logger: homeassistant
Source: components/caldav/calendar.py:87
First occurred: 19.45.23 (1 occurrences)
Last logged: 19.45.23

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/caldav/calendar.py", line 87, in setup_platform
    calendars = client.principal().calendars()
  File "/usr/local/lib/python3.9/site-packages/caldav/davclient.py", line 350, in principal
    self._principal = Principal(client=self, *largs, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 399, in __init__
    cup = self.get_property(dav.CurrentUserPrincipal())
  File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 174, in get_property
    foo = self.get_properties([prop], **passthrough)
  File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 197, in get_properties
    response = self._query_properties(props, depth)
  File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 141, in _query_properties
    return self._query(root, depth)
  File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 159, in _query
    ret = getattr(self.client, query_method)(
  File "/usr/local/lib/python3.9/site-packages/caldav/davclient.py", line 398, in propfind
    return self.request(url or self.url, "PROPFIND", props,
  File "/usr/local/lib/python3.9/site-packages/caldav/davclient.py", line 577, in request
    self.verify_login()
  File "/usr/local/lib/python3.9/site-packages/caldav/davclient.py", line 560, in verify_login
    raise error.AuthorizationError(url=url, reason=resp.reason)
caldav.lib.error.AuthorizationError: AuthorizationError at 'https://caldav.icloud.com', reason 'Service Unavailable'

Has the caldav icloud server changed?

Don’t have any problems.

Woooooo! Renaming “Family” to “Ye Olde Family” (guessing anything else would have worked) solved this for me. Thank you!

I realise this is an oldish thread but am having issues with iCloud calendars. I followed the integration exactly and calendar was showing and worked well for some weeks.
It stopped working abruptly - not linked to any update as far as I can tell. It now shows “Could not retrieve events for calendars”

Trying to fix it I eventually deleted the integration in configuration.yaml and reinstalled it.
Doing this, I now have no entities in the HA list at all. I have used exactly the format, added in the secrets for username and password - but nothing.

What might I be missing???
I’m relatively new to HA and YAML so it is entirely likely I’ve missed something obvious
Thanks very much in advance!
(Using Home Assistant 2023.1.7 Supervisor 2023.01.1 Operating System 9.4 Frontend 20230110.0 - latest)

You don’t have, by chance, added Yubikey (or other) security keys to your iCloud account?