Cannot get iCalendar to retrieve iCloud calendar

So, I finally bit the bullet and upgraded to OH3.0 tonight. It was a bit painful, but mostly at least able to be resolved with some googling and some searching of these forums. But now I’m really stuck on the last bit of functionality I’m trying to recover from the previous system: how to get my iCloud calendars feeding in through the iCalendar binding.

I extracted the URL for the calendar from my old caldavio.cfg file, and tried it with and without adding “?export” to the end of it, filled in the account username and password again taken straight from the caldavio.cfg file, put in the default values for refresh and max calendar size and… the thing doesn’t work.

The only feedback I get is a singularly useless error message (at least, google didn’t turn up any clearly relevant hits) in the log, as follows:

03:40:42.189 [WARN ] [ng.icalendar.internal.handler.PullJob] - Response status for getting "https://p60-caldav.icloud.com:443/.../calendars/work/?export" was 405 instead of 200. Ignoring it.

I’ve tried pasting the same URL into a browser, and I get the equivalent message: “method not allowed”. But it definitely is the URL from the caldav config file, and I get a different response in the browser if I intentionally enter the wrong user/pass combo, so it is still authenticating correctly at that address… just that the instructions I used way back when to get the URL for the caldav system do not seem to be the way to get the correct URL for the iCalendar system?

I really don’t want to lose this functionality, but I can’t find out how to transform the settings I had working in CalDAV to work in the new iCalendar binding.

How does your config look like ? Do you use a .things file or the UI ?
Are you aware of the breaking changes in OH3: iCalendar - Bindings | openHAB ?

I had tried the UI only, because I figured that was less likely to mess up something important in the config. But I’m going to try creating a .things file instead, since the UI didn’t work. Will post the things file and the results (if any different) here shortly.

OK - I’ve tried it with a .things file now, and it appears in the UI looking pretty much as my setup in the UI looked before. Here’s the bridge code:

Bridge icalendar:calendar:robinwork    "Robin's Work Calendar" @ "Internet" [ url="https://p60-caldav.icloud.com:443/xxxxxx/calendars/work/", refreshTime=60, username="xxx@xxx.xxx", password="xxxx-xxxx-xxxx-xxxx", maxSize=4 ] // generated new app-specific password

The error now being generated in the log is:

00:31:02.511 [WARN ] [ng.icalendar.internal.handler.PullJob] - Download of calendar timed out (waited too long for headers).

… which unfortunately is less informative than the previous error. When I paste that URL into a browser and supply the correct login credentials, I still see “Method not allowed” (i.e. an HTTP 405 error).

I’ve also tried setting up a public calendar and pasting that in (as suggested in Small Guide to icalendar), but any time I replace “webcal:” with “https:” or “http:”, it gives a 404 error… so it looks like that’s a dead end too. Would really like to see anyone’s config if you’ve got an iCloud calendar working with the iCalendar binding!

OK - I’ve made a lot of progress on this tonight, so I will share the key step that enabled me to make that progress, in case anyone else is struggling to get iCalendar to work with iCloud calendars: there’s a tiny but crucially important missing step in using the public calendar technique as mentioned in Small Guide to icalendar.

The original post says you should replace “webcal:” with “http:” or “https:”. And that’s true - you do need to replace it with https:. But you ALSO need to replace another part of the URL.

For example, the original URL might be:

webcal://p47-caldav.icloud.com/published/2/AAAAAABCDEFgHiJKlmnop

But the URL you will need to put in the iCalendar thing is:

https://p47-calendars.icloud.com/published/2/AAAAAABCDEFgHiJKlmnop

If you don’t make the second replacement, it gives a 404 error. But if you replace both… sweet, sweet calendar data!

It’s not authenticated access yet, so technically I’ve had to make those calendars “public” in order to use them… but presumably if I’m not trading in state secrets, the chances of anyone stumbling across the full sharing URL (if I don’t put it anywhere but in a .things file) is pretty minimal.

1 Like

Nice that you could solve it. However, trying again whether that part in the tutorial is still right, i was not able to verify this behaviour and did not need to replace anything but the protocol.

This is testable by just pasting the URL into a browser. If a file gets downloaded you can open the file in an editor. If you can see iCal-tags like BEGIN:VCALENDAR the tried URL is correct.

OK, that’s just weird. I tried that before - without changing “caldav” to “calendars” in the URL, and it gave me a 404 error when pasted into a browser. I’ve just tried it again (just changing webcal, not the other bit in the URL) and it’s working. I mean, this is an iCloud issue rather than an openHAB issue now, but still… that’s thoroughly bizarre. Thanks for the cross-check… I guess maybe if just changing the protocol isn’t enough, try editing the hostname portion of the URL as well?

Thanks for this information.

I used CalDAV which was working well.
After changing the URL as you mentioned above, I am still not able to connect.
However, I use my credentials from CalDav, which worked well on OH2.5 and Caldav.
Did you ever make it work with user / password?

EDIT:
When using curl with the same adress according to this thread I get all my calendar data:

Anyone who has running this on OH3 with user / passwd?

I couldn’t get it working with authenticated access, but in the end there isn’t anything desperately high-security in the calendars I want to access, so I’ve just set them up with “public” sharing (and then I just won’t give those links to anyone except my openHAB config file).

Functionally I don’t think it’s a security issue, but it seems like perhaps authenticated access to iCloud calendars would be a good feature to add to the iCalendar binding in future?

Yes, there seems to be something wrong.
I can access the calendar with curl, but it won’t share any appointment in there.

But even on public calendars I don’t get my thing online.
I guess I need to play around a little more.
I still get:

The calendar is currently offline as no local copy exists. It will go online as soon as a valid valid calendar is retrieved.

EDIT:
I can call successfully the URL of my public calendar in the browser (with both caldav AND calendars), but my thing stays offline.

EDIT II:
Just to make sure: I am on 3.0.1. stable

EDIT III:
After a reboot, the iCalender went ONLINE.
However, the channels are UNDEF :frowning:

EDIT IV :slight_smile:
It took a while, but it works now. (without user / passwd)

Anyone knows about an update for iCalendar binding to work with private calendars instead of public only?

I am also having issues with private calendars. I use caldav (I’m actually the author of the quoted post above) and this is one of the last things I need to complete before a complete move to OH3

I use openHAB calendar as a secondary lens to my family calendars if I went public I think my family would lose the ability to add to the calendar on their phones/computer/whatever so this is not an option

It’s weird there is a username and password field I’d it doesn’t support private?

I agree that it would be better if the openhab binding could handle authenticated access, however using the “public calendar” option is compatible with access for specific people. I am using calendars with OpenHAB that simultaneously have user-specific access (for humans) and public sharing (for OH).

Well that’s interesting- can you share how you got it working? I tried changing the url to calendars instead of caldav but this just gave me the standard error and my bridge remains offline

So you are saying you have a public calendar AND it is shared with people with edit access?

The “small guide to iCalendar” instructions, along with my change from ‘caldav’ to ‘calendars’ mid-URL (which I subsequently changed back without a problem?) was everything I did to get OH retrieving my calendar - however I absolutely did need to turn on public calendar sharing.

That’s the result of both public sharing (read only) and individual sharing (full edit access).

You just need to add the individuals to share with in the middle “Share With…” section and then tick the box for Public Calendar below that.

Screen Shot 2022-01-01 at 15.10.18

Ok that’s good to hear - I created a test calendar and did public sharing, copied the link - changed to https and tried both calendars and caldav and waited a good hour with no luck the bridge going online - can u think of anything else I’ve missed? The public link does seem very long but adding it to a browser allows me to download the ics file (with caldav or calendars)

With the shared public and private - any idea how to convert what is currently a private TO a public? No google chi seems to be working for me

Ok I have successfully got three calendar bridges online - I thi j the magic combination was this:

  1. Create the bridge and copy and paste the URL from the public link in iCloud
  2. Change the URL to start with https
  3. Go back to your calendar and tick private AS WELL and then share with a family member
  • this seemed to make the bridge come online automatically.

For anyone reading along my other question was how do I change a private calendar to a public - what I actually had was a family sharing calendar set up - if you’ve done this you don’t see the private or public tick boxes in iCloud - BUT if you go to the settings on the calendar on your IOS device you see them there as well as the link you need for the bridge

My only thing to do now is work out how to pull the next 5 events from a calendar using the event filter - I thought I could create a thing and leave all the optional values blank and it would give me this - at the moment it’s not giving me the next five but the next something as if it has filter criteria on it but I’m glad I have made significant progress and the need for caldav in OH3 is gone and this binding is working

Ok last post from me as I have it all working great now - the event filter needs to be set to day filter of 0 otherwise it brings back the very first event in your calendar from years ago - 0 equals “now”. Which is in the doco…
I also had to upgrade to 3.3.0 latest as there’s a http request issue that was preventing updates but it’s all working great now