[TUTORIAL] Trigger a flow using calendar events

You can trigger flows on your calendar events, using the icalCalendar app.

Setup

First thing we need to do is to add your calendar to the app. You have the possibility to add one ore more calendars. IcalCalendar works with Apple, Outlook and Gmail calendars but in theory it should work with any provider asl long as they expose a public ical url (*.ics).
Open the app settings (configure app) and paste in the ical link and give your calendar a name.
If you do not know where to find the link you have to paste, please follow the instructions below:

When you use an Exchange or Outlook calendar:

  1. Go to Outlook
  2. Click settings → Show all outlook setting
  3. Go to Calendar → Shared calendars
  4. Publish a calendar, click the ics link and choose copy
  5. Paste the ical link in settings of Homey app

When you use a Gmail calendar:

  1. Go to Google
  2. Click the three dots next to the calendar you want to share → Click Settings and sharing
  3. Scroll all the way down to the bottom
  4. Copy the link from Secret address in ical format
  5. Paste the ical link in settings of Homey app

When you use an Apple calendar:

  1. Go to Apple , or open the Calendar app on your iOS device or Mac.
  2. Click on the icon next to the calendar name in the left pane
  3. Tick the checkbox for Public calendar
  4. Copy the link
  5. Paste the calendar link in the Homey app settings
    It must be the original link (Apple Calendar has case sensitive urls)

The Date and Time format used in the app can be changed in the settings. If you not change it, the default is used.

Format date:

  • DD = day
  • MM = month
  • YY or YYYY = year

Separated by / - or .

Format time:

  • HH or hh = hour (24h or 12h)
  • mm = minutes

Separated by : or .

Usage

Now you have added your calendar, it is time create a flow that will be triggered.

Triggers

  • Event starts - will trigger when any event starts**
  • Event starts from calendar - will trigger when a specific calendar is selected
  • Event starts in - will trigger when any event starts in when specified
  • Event stops - will trigger when any event stops

Create a new flow and add the card: “Event starts”
If you want to add a logic card to AND, you have the possibility to add some flow tokens (tags):

Flow tokens on triggers

  • Event title
  • Event description
  • Event location
  • Event duration
  • Event duration (minutes)
  • Calendar name

The tag information is coming from your agenda.
When you have selected as first card: “Event stats in”, then you are able to add a time variable to it. Enter the amount and unit [Minute, Hour, Day, Week].

You can also add an extra condition. Therefore select “AND” and select the icalCalender app. You see the following conditions:

  • Specific event is ongoing - will check if specific event is or isn’t ongoing
  • Specific event starts within - will check if specific event starts or doesn’t start within when specified
  • Specific event stops within - will check if specific event stops or doesn’t stop within when specified

Finalise your flow adding the THEN section and save the flow.
If you select in the THEN section the icalCalendar app, you can add the card: Sync calendars. This will download new .ics files to update current events.

If you want to add in one of your current flows an icalCalendar token (tag), you can find and add them by:

  • Select Tag
  • Search: icalCalendar

Global flow tokens

  • Next event title
  • Next event start date
  • Next event start time
  • Next event stop date
  • Next event stop time
  • Next event duration
  • Next event duration (minutes)
  • Next event starts in (minutes)
  • Next event stops in (minutes)
  • Calendar name of next event
  • Todays events, title and time
  • Todays events (count)
  • Tomorrows events, title and time
  • Tomorrows events (count)
  • Todays events (per calendar)
  • Tomorrows events (per calendar)

These tokens can be used in any app and service.

Next event tags per calendar (can be turned on in the settings)

  • Next event title in %calendarname%
  • Next event start date in %calendarname%
  • Next event start time in %calendarname%
  • Next event stop date in %calendarname%
  • Next event stop time in %calendarname%

Synchronising

  • The icalCalendar app will automatically sync your calendar every 15 minutes
  • The Sync calendars action flow card can also be used to trigger a sync
  • Only events not started yet or events started but not finished will be fetched
  • Recurring events where start date is within 2 months or less will be fetched

Recurring events

Be aware of multiple/duplicate “recurring” events:
On a recurring event, where one or more participants have declined, that specific event is detached from the recurring event and created as a separate non-recurring event. This can result in two similar events, both have the same name and date.

Ideas & Issues

If you have any ideas or issues, create a ticket in the project on GitHub

18 Likes

Hi.
Any Idea why the following Flow won’t work? :

This one does work:

The only difference that I can see is that one is triggered on event start, and the other on event ends.

Calendat is syncing with homey just fine.

Hi there.

Just did a test at my end with “Event starts” and “Event ends” and both worked as they should.

In the “Og” section, have you chosen the correct tag? What if you rechoose the Title tag? And are you absolutely sure the event has the word “Jobb” somewhere in the title/summary?

I have rechosen the title tag several times. The event has the title “Jobb” I have also tried using ‘exactly’ instead of ‘including’ for the logic. No difference.
I don’t understand why it won’t work.

You can look at the events IcalCalendar imports from your calendar, to check what the title and start/stop time of the event actually is:

  • Create a new flow
  • In the ‘And’ section choose ‘Specific event is ongoing’ and click on ‘Select event…’
  • This will present a list with all the calendar events IcalCalendar has imported from your calendar.
1 Like

Hi.
What about public calendar and multiple calendars?
I added next to my private calendar public calendars for sport events. I do not see any events coming up? For my private it is working fine. Anyone could help?

IcalCalendar can in theory import calendar events from any calendar provider as long as the calendar can be shared with a public *.ics uri and the *.ics is in standard RFC5545 format.

You can add multiple calendar uris in the settings page.

If you would like to check which events IcalCalendar will retrieve from your calendar, you can use the new test tool (nodejs app) i have put together to test calendar behavior: GitHub - runely/calendar-homey-test: Test IcalCalendar behavior

1 Like

Hi again.
I still have problems getting my flow to work and I have a suspicion/idea why.
What I want is a trigger 30 minutes before I finish work. My work shifts are all in my calender as recurring appointments.

I work nights and so the entries in the celandar crosses over from one date into the next.

Could this be what is causing it to not function on the end time?

It is strange though, as the times and dates are listet correctly in homey.

Hi

I have done a lot of tests here and i can not reproduce this. Calendar events crossing over one day or multiple days work as expected here.
Is this only a problem with events crossing over to the next day? Or is this a problem with all of your events?

I did however find a bug which would prevent Event ends in to trigger when Event ends in amount is set to same time as when the event starts. I don’t think this bug has affected you for this issue.

Example of who this bug can affect:
There's an event that is set to start at 15:00 and ends 15:30, and you have an 'Event ends in' trigger card setup to trigger 30 minutes before an event ends.

This bug is fixed in the next release

I have done some further testing and it seems to only be a problem with repeating events (for instance: “Repeats every two weeks, on mondays and tuesdays”).
Did you try this when you did your tests?

It works if i create a single event. Even if it crosses over days.
But it won’t be practical for me to create a separate event for every single work shift.

Repeating events displays differently in the calendar on my phone:

The events named Jobb are repeating events, while the one named Test is one single event. But as you can see, all the events go from one day to the next. Perhaps this is why homey has trouble? It seems to me, the repeating events dissapear from homey at midnight even though they are not completed.

As you can see, the Test event is showing in homeys list, but my repeating Jobb event is not visible (only the next one, starting later tonight)

I did not test with recurring events… And i see the problem now. Thanks for reporting it! Could you please create an issue on GitHub and i will fix this for the next release!

Done. Thank you for your effort.

This is fixed in the next release, 0.6.5, and is sent to Athom for review :+1:

1 Like

That was fast. Thank you again.

1 Like

I have released a new test version (0.14.2) which includes a date time bugfix.

Recurring events set to start at 00:00 would be misread by IcalCalendar to 01:00.
This is fixed, at least for us which is on GMT+1 timezone.

Could someone, preferably, on another timezone than GMT+1 test this test version and comment here with the results?

1 Like

You can change your location to any timezone you like, and test right away.
...More > Settings > Location
Switch “let Homey find my location” to off.

Ahh. Of course, didn’t think about that! Thank you :+1:

1 Like

Hello, i hope someone can help me.

is there a easy card to switch something (a lamp or a flow) on specific word/tag?
I did find a card to look at find a event with a specific word/tag in X days and do something after that, but didn’t find that one when ending with a specific word/tag in X days.

Or is the a better way to do something after ending a event?

Thanks for your help.

This card i did find:

Sorry, but I don’t understand exactly what you want to do. Maybe others do.
Do you want to turn on a lamp when an event starts in the calendar. And when the event ends turn off the lamp again? Or what?

I like to change a Flow when i’m in Berlin.
Flow “A” is a flow with all the lights in the house on.
Flow “B” is a flow with only a view lights.

When i go to Berlin i like to switch to flow “A”, when i leave Berlin i like to Switch to Flow “B”.

I did find a card in icalCalender that scans with a tag to start the event, but can’t find a card that stops the event.

I did find this one, it’s works great for start, but not for stop it.
Homey - Flow card iCal 02