Homey Community Forum

[TUTOTIAL] 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

12 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.

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