iCloud Calendar integration

I’m trying to get my iCloud calendar integrated with the CalDav component.
I have created an app password for iCloud because I have 2FA enabled.

I’ve used this method to get the caldav url:

The config I used is:
calendar:
  - platform: caldav
    username: !secret icloud_login
    password: !secret icloud_password
    url: !secret icloud_url
    calendars:
      - "Family"

When I apply this config I’m getting errors. When I try whitout “calendars”, I’m getting errors.
Is there someone that can put me in the right direction?

The errors:
2019-04-20 07:52:45 ERROR (MainThread) [homeassistant.components.calendar] Error while setting up platform caldav
Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, 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/app/homeassistant/components/caldav/calendar.py”, line 62, in setup_platform
calendars = client.principal().calendars()
File “/usr/local/lib/python3.7/site-packages/caldav/objects.py”, line 354, in calendars
return self.calendar_home_set.calendars()
File “/usr/local/lib/python3.7/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 “/usr/local/lib/python3.7/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’

And:
2019-04-20 07:35:30 ERROR (MainThread) [homeassistant.components.calendar] Error while setting up platform caldav
Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, 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/app/homeassistant/components/caldav/calendar.py”, line 62, in setup_platform
calendars = client.principal().calendars()
File “/usr/local/lib/python3.7/site-packages/caldav/davclient.py”, line 113, in principal
return Principal(self)
File “/usr/local/lib/python3.7/site-packages/caldav/objects.py”, line 316, in init
cup = self.get_properties([dav.CurrentUserPrincipal()])
File “/usr/local/lib/python3.7/site-packages/caldav/objects.py”, line 183, in get_properties
properties = self._handle_prop_response(response, props)
File “/usr/local/lib/python3.7/site-packages/caldav/objects.py”, line 147, in _handle_prop_response
if not ’ 200 ’ in status.text and not ’ 207 ’ in status.text and not ’ 404 ’ in status.text:
AttributeError: ‘NoneType’ object has no attribute ‘text’

I’ve solved the issue. For other iCloud users, here the solution:
The problem was the caldav lib. I’ve created an PR for this:
https://github.com/python-caldav/caldav/pull/56

The PR is merged, so it should work soon without modifications. Till then i’ve copied the caldav (https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/caldav/calendar.py) component to the custom component dir and added the line to the file:
REQUIREMENTS = [‘https://github.com/ZiroNL/caldav/archive/icloud01.zip#caldav==icloud01’]

It’s now loading the lib from my own github.

2 Likes

Do we still need the workaround now ?

Jan

Doesn’t work for me so I guess so, still looking on how this workaround works. But I guess I’ll need to add that line at the top of the calendar.js file right?

Home Assistant uses the caldav lib 0.6.1 (https://github.com/home-assistant/home-assistant/blob/4f8a93fb3e1cf61decc05a8e55fa254298168915/homeassistant/components/caldav/manifest.json)

For iCloud we need 0.6.2 (https://github.com/python-caldav/caldav/releases/tag/v0.6.2), this is the version with the fix.

I will try to create an PR for Home Assistant so iCloud caldav works again by default.

1 Like

Caldav 0.6.2 is not released yet, see https://github.com/python-caldav/caldav/issues/68.
So I can not create an PR for home assistant yet.

Any news on iCloud Calendar support in Home Assistant yet?

Cant wait till we can use iCloud Calendar in HA…

im using my iCloud calendar with Ha just had to integrate the caldav component https://www.home-assistant.io/components/caldav/:

calendar
  - platform: caldav
    url: https://caldav.icloud.com
    username: "your-apple-id-login-name-something-like-an-email-address"
    password: "super-secret-app-spezific-password-you-can-get-in-the-appleid-2-factor-settings"

after that all calendars get synced with HA, im only struggling to get the reminder working - i can see the calendar but there are no events in it. does anyone has a clue?

3 Likes

Hi,

I have this configuration:

---
# The caldav platform allows you to connect to your WebDav calendar and generate binary sensors.
# A different sensor will be created for each individual calendar, or you can specify custom calendars
# which match a criteria you define (more on that below). These sensors will be on if you have an on
# going event in that calendar or off if the event is later in time, or if there is no event at all.
# The WebDav calendar get updated roughly every 15 minutes.
#
# https://www.home-assistant.io/components/caldav/
#


calendar:
  - platform: caldav
    username: !secret icloud_username
    password: !secret icloud_app_specific_password
    url: !secret icloud_url
    calendars:
      - Familie

The icloud_url is https://caldav.icloud.com

In lovelace I use the Calendar Card:

dateBottomFormat: ddd
dateTopFormat: DD
entities:
  - entity: calendar.familie
    name: Gezinsagenda
hideHeader: false
hideTime: false
numberOfDays: '2'
progressBar: true
showEventOrigin: false
showLocation: false
showLocationIcon: false
showMultiDay: false
startFromToday: false
timeFormat: 'HH:mm'
title: Gezinsagenda
type: 'custom:calendar-card'

The result is:

6 Likes

I dont get it to work. i get the following error

2019-10-15 14:20:12 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 399, in _async_add_entity
raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: calendar.family

My config is

calendar:
  - platform: caldav
    url: https://caldav.icloud.com
    username: 'icloud emailadres'
    password: 'xxxx-xxxx-xxxx-xxxx'
    calendars:
      - "Family"

Could you format your code?

like this?

Interesting, I got exactly the same message, but couldn’t figure out why. I assumed it was because I had a “Family” Google calendar for a while, so I just renamed the calendar in iCloud and it worked :man_shrugging:

error message is now gone. but still noting in mij calendar

Did you alter the calendar in your code? Look at my example. And to be sure, delete Family in your entitiy registry.

Insert Facepalm Here!!! :laughing:

Thanks for your help!!!

1 Like

I’m also trying to configure this integration, but i get this error message in the log:

Exception: The CalDAV server you are using has a problem with path handling.

My configuration is as follow:

calendar:
  - platform: caldav
    username: !secret icloud_username
    password: !secret icloud_generated_password
    url: !secret icloud_url

username is my Apple ID email address
password is a generated password from appleid.apple.com
url goes to https://caldav.icloud.com

Does somebody know what the problem is?

Thank you in advance

Which calendar are you using? Specify this in your YAML code.

I have the same problem, this error occurs in the logbook:

“Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 399, in _async_add_entity
raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: calendar.family”

I have use this code:

calendar:
  - platform: caldav
    username: !secret icloud_username
    password: !secret icloud_app_specific_password
    url: !secret icloud_url
    calendars:
      - `Family`

There is no entity Family in the entity register