HowTo: Connect iCal to "calDav Personal Binding"

Hi,

because it was a bit hard to find all the steps needed to configure my iCloud calender (iCal) to calDav-Binding - i will list here the steps for the others coming up with it
( by the way, thanks to @Andrew_Pawelski and his “ical-connection” thread here )

for this HowTo, you only need the "CalDAV Personal Binding"

  1. Log into your Apple-ID at appleid.apple.com ( not www.icloud.com! ) . Confirm your login by entering the two-factor identification code sent. Once logged in, look for the section in your Apple ID control panel labeled “Security” and click on “Generate Password”

  1. When prompted, label the app-specific password whatever you want eg “OpenHab” and click “Create”.

  2. Apple will provide you with a randomly generated alphanumeric string in the format xxx-xxxx-xxxx-xxxx. Highlight and copy the password and keep it somewhere safe.

  3. Go on your Mac to your ~/Library/Calendars folder

  4. You will see some folders with long string names, there should be one, with .caldav at the end

  5. in this folder, there are maybe again a lot of long string folders, just go inside one of them and check the inside of info.plist

  6. search for CalenderPath - there should be a string looking like this:
    ( the “0123456789” is the USER_ID )

<key>CalendarPath</key>
<string>/0123456789/calendars/XXX-XXXX-XXXXXX-XXXXXXXXXXXXXX/</string>

  1. now lets find the server adress, open Terminal and type,
    replace this:
    XXXXXXXXXX = your EMAIL adress ( icloud )
    0123456789 = your USER_ID ( from step 7 above )
curl -s -X PROPFIND -u "XXXXXXXXX" -H "Depth: 0"  --data "<propfind xmlns='DAV:' xmlns:cd='urn:ietf:params:xml:ns:caldav'><prop><cd:calendar-home-set/></prop></propfind>"  https://calendars.icloud.com/0123456789/principal/
  1. ENTER
    password = type the app-specific password from step 3

  2. hopefully you get something like this output:

<calendar-home-set xmlns="urn:ietf:params:xml:ns:caldav"><href xmlns="DAV:">https://p99-caldav.icloud.com:443/0123456789/calendars/</href></calendar-home-set>
  1. we know the Server Adress now ( p99 / Port: 443 )
https://p99-caldav.icloud.com:443/0123456789/calendars/
  1. lets check the available calenders with:
    ( replace email & url in the curl command )
curl -s -X PROPFIND -u "XXXXXXXXX" -H "Depth: 1"  --data "<propfind xmlns='DAV:'><prop><displayname/></prop></propfind>"  https://p99-caldav.icloud.com:443/0123456789/calendars/ | grep displayname

password = type the app-specific password from step 3

you should see somthing like this - we need the XXXXXXXX-Part for the .cfg file

<response>
                <href>/0123456789/calendars/XXXXXXXXXXXXXXX/</href>
                    <propstat>
                        <prop>
                                    <displayname>Büro</displayname>
                            </prop>
                            <status>HTTP/1.1 200 OK</status>
                    </propstat>
        </response>
  1. now lets configure the caldavio.cfg
caldavio:YYYYYY:url=https://p99-caldav.icloud.com:443/0123456789/calendars/XXXXXXXXXXXXXXXXXX/
caldavio:YYYYYY:username=XXXX@icloud.com
caldavio:YYYYYY:password=XXXXXXXXX // your key from step 3 (not your iCloud account password)
caldavio:YYYYYY:reloadInterval=1440  // 24 hours interval  ( Put 1 while testing)
caldavio:YYYYYY:preloadTime=30     // events in the past
caldavio:YYYYYY:disableCertificateVerification=false

YYYYYY = choose your calender name
username = iCloud Account
password = the key made in step 3
url = edit the p99, 0123456789, XXXXXXXXX to your informations given above

  1. maybe again restart openhab and hope that helped and you made it workin :wink:
  2. just for displaying events, there is no need to edit the caldavPersonal.cfg

ITEMS
String      OfficeCalName0	    "Termin jetzt [%s]"		                <calendar>  (gDummy)	{ caldavPersonal="calendar:YYYYYY type:ACTIVE eventNr:1 value:NAME" } //eventNr for concurrent events
DateTime    OfficeCalTime0	    "Beginn [%1$tT, %1$td.%1$tm.%1$tY]"		<calendar>  (gDummy)	{ caldavPersonal="calendar:YYYYYY type:ACTIVE eventNr:1 value:START" } //eventNr for concurrent events
String      OfficeCalName1	    "nächster Termin [%s]"	                <calendar>  (gDummy)	{ caldavPersonal="calendar:YYYYYY type:UPCOMING eventNr:1 value:NAME" }
DateTime    OfficeCalTime1	    "Beginn [%1$tT, %1$td.%1$tm.%1$tY]"		<calendar>  (gDummy)	{ caldavPersonal="calendar:YYYYYY type:UPCOMING eventNr:1 value:START" }
String      OfficeCalName2	    "übernächster Termin [%s]"              <calendar>  (gDummy)    { caldavPersonal="calendar:YYYYYY type:UPCOMING eventNr:2 value:NAME" }
DateTime    OfficeCalTime2	    "Beginn [%1$tT, %1$td.%1$tm.%1$tY]"     <calendar>  (gDummy)    { caldavPersonal="calendar:YYYYYY type:UPCOMING eventNr:2 value:START" }
Helpful Links

• Determing the URL of CalDAV Calendars ( iCloud, Google, Baikal, OwnCloud )
http://www.ict4g.net/adolfo/notes/2015/07/04/determingurlofcaldav.html

• Another Thread - same topic:
[SOLVED] Apple icloud CalDav connection

Github
https://github.com/openhab/openhab1-addons/wiki/CalDAV

Troubleshooting

if you see nothing displayed in the sitemap - check if you see the .ics files (step below)

when you see the .ics files, but nothing displayed in the sitemap - maybe you picked the wrong calender (e.g. shopping-list) - the sitemap cant display anything - change the “Folder-Number” in the caldavio.cfg file

maybe you have a wrong config file from ealier attemps stored in

/var/lib/openhab2/config/org/openhab/

Remove (or edit) all* .config files which are related to caldavio (caldavio.config, caldavPersonal.config, caldavCommand.config, i.e. “NameOfYourCalendar.config”).

After removing these files restart openhab
and check if your events are stored as *.ics files in

/var/lib/openhab2/etc/caldav/"nameOfYourCalendar"/

Check your Log for Infos
For Console ( KARAF) - i dunno which one helped for :

 log:set TRACE org.openhab.binding.caldav_personal
 log:set TRACE org.openhab.binding.caldav_personal.CalDavBindingProvider
 log:set TRACE org.openhab.io.caldav.CalDavLoader 

Clear Cache:

sudo /etc/init.d/openhab2 stop
sudo rm -rf /var/lib/openhab2/cache/*
sudo rm -rf /var/lib/openhab2/tmp/*
sudo /etc/init.d/openhab2 start

hopefully that helped you - good luck :slight_smile:

3 Likes

hi is your calendar still working I am getting UNDEF in UI but all ics files in right locations even when deleting them they reload

just for info

the calender only works from:
today till the next 14 days - i think

still no luck? check settings again

Did you ever get this figured out? I’m in the same situation as you. All items are UNDEF even though I have events during the next few days.

Thanks very much for putting this together. You need to remove | grep displayname from the code to display the correct data.

1 Like

The problem has gone away but by itself and without me knowing what it was - I have a feeling it messed up a recurring calendar item with a null end date - I cleared all caches and files and it was still failing but then it suddenly started working again sorry I can’t be of more clarity

sorry for necro´ing this post but i managed to configure this properly thanks to your both tutorials.
thanks again for your efforts here.

the problem is, i get the following error in the log:

2019-01-21 23:16:10.221 [thome.event.ExtensionEvent] - Extension 'binding-caldav-personal1' has been installed.

2019-01-21 23:39:18.983 [INFO ] [.io.caldav.internal.CalDavLoaderImpl] - CalDAV IO is properly configured.
2019-01-21 23:39:18.992 [INFO ] [b.core.service.AbstractActiveService] - CalDav Loader has been started
2019-01-21 23:39:19.032 [INFO ] [.io.caldav.internal.CalDavLoaderImpl] - reload job scheduled for: Familienkalender
2019-01-21 23:39:35.697 [WARN ] [caldav.internal.job.EventReloaderJob] - Sardine error while loading calendar entries: Unexpected response (404 - Not Found)

so what i read from this, the calendar is fetched correctly (Familienkalender) but then it runs in a 404…
any clues here ?

thanks, markus

404 Not Found probably means you’ve configured the wrong URL for your calendar.

What Do you mean by that - so where to look for them?
I get UNDEF as well and am quite sure that every thing is cionfigured ok.
(just went through the steps above the 3rd time).

/var/lib/openhab2/etc/caldav is the path then there should be a folder per calendar and inside this all the ICS files that match the period in your configuration file

Awesome, thanks!
I will check it out

EDIT: There is nothing :unamused:

@NCO - Check whether all your entries were made with google calendar or not. My wife’s iphone is linked to our google calendar and I noticed when she made entries with her iphone apple calendar it caused some issues (404 errors).