iCalendar binding

Tags: #<Tag:0x00007f5c93877db8>

As some of you already noticed, i have been building a binding for using ical-calendars as source for presence switches. Now is the time i’m sure i’ll get it done in a way it is maintainable and will be stable for daily use.

  • The good: It already works as i expect, it follows at bit KISS, it contains unit-tests for the algorithm, the iCal-implementation is encapsulated enough so a replacement is easy
  • The bad: There are some known issues (e.g. the calendar pulls first time after the configurable refreshtime, another parameter is currently ignored but planned to be implemented)
  • The ugly: It uses a 3-rd party dependency for parsing iCals as i did not want to reinvent this

So it is currently not mainline-ready. But i’m working on it. Here is the source: https://github.com/daMihe/openhab2-addons (direct: https://github.com/daMihe/openhab2-addons/tree/create-icalpresence/bundles/org.openhab.binding.icalpresence)

@so many users from this forum helping me understanding my issues: a big thank you!


This looks great and finally I would be able to switch from the old Caldav binding.

One question: Does the presence switch has some pattern-matching filter (like regex?). I have a calendar with lots of events in it, I want to view them all, but not to toggle the presence switch if it is not an event with a specific name for example.
The old Caldav binding seems to have a regex filter, but I failed to get it working, even with help. Would be really great if this would work on this binding.

This is currently not possible. For now, i want to release it to ensure it is usable for many people. I plan to add a filter after the first release by regular expressions or categories. But this would also cause to not be displayed.

Your plan is to only switch specific events? This could be done with a rule like this (untested, but could work):

rule "special-switch"
    Item presence_switch changed or
    System started
   if (presence_switch.state == ON) {
       if (current_event.state.toString.matches("^o[0-9]")) {
   } else {

This requires you to set up a Switch as item called virtual_presence, which can be used for switching other items.

Some Update on state:

  • The initial feature set is complete. There is PR 6453 opened a while ago and it got already a bugfix
  • I’ve got some positive feedback about function from a user

Some Update:

  • @AndrewFG wants to contribute a triggering mechanism for event starts and events, so specific commands can be done by event.
  • As this change will do more than presence we decided to rename the binding from ‘icalpresence’ to ‘icalendar’
  • As the binding-MR was not accepted before OH 2.5 we’ll not wait before building further things

Will the 1.x caldav-personal and caldav-command functionality be built into this binding?

The binding is meant to reimplement parts of the calendar thing in openhab2/3 state of art. But there will be no ability for writing events into calendars automatically, as the way we access the calendars is simpler. The “replacement” for caldav-personal just shows if an event ist present and some details. Please take a look at the README for the current state: https://github.com/daMihe/openhab2-addons/blob/create-icalpresence/bundles/org.openhab.binding.icalendar/README.md

For caldav-command i don’t have a usecase, so i’m not fully aware of which parts will be implemented. The only thing i can assure is that the binding will not be able to modify the calendar.

1 Like

Update about the state: @AndrewFG contributed the command-trigger part using the event bus of openhab. This is cool and works. It’s built a bit like the old caldav-command-binding.

However the commit history was screwed up while integrating his changes into my merge request. So i’ve cleaned up the repository and created a new MR (simply said), see there:

The repaired repository is accessible at https://github.com/daMihe/openhab2-addons/tree/create-icalendar-squashed/bundles/org.openhab.binding.icalendar

1 Like

I have started migrating to this one. One thing I really miss, is a Title which shows the current and upcoming event title as well (current is there is something currently and upcoming if there is no current event), this was supported by the old caldav binding.

Also does someone was able to get iCloud working with this? Seems that webcal links are not supported, only http

Nice to read! webcal should be no problem - just replace webcal:// by http:// or https://, it should work and is only a hint for operating systems the URL is a calendar to open the right application AFAIK. The “hybrid” title is currently not implemented, you could solve this by implementing a virtual item filling it by reading out both in a rule.

1 Like

Thanks it works!