Outlook Calendar Automation Issue

I am using O365 Outlook Calendar and would like to see how I would setup an automation to only look at event calendar “Location” & “Event Start Time”

Criteria:

  1. Check event calendar and depending on the “Location” and if the event is within 1 hour of start time it will trigger a device (each location will trigger a different device to turn on)

  2. At the end of each event it will trigger the device off.

Hi Freddy, welcome to the forum!

For this to work you first need a way to integrate that Outlook Calendar with HA.
There is no such thing in the official integrations for Outlook but this might get you there: Outlook Calendar Integration

Once you get your Calendar in HA, in an automation you use the Calendar trigger.

Hello Nick, thank you for replying back, sorry I didn’t make it clear in my post that I already have outlook intergraded so I already see all the events from my outlook calendar, the part that I am having issues on is the automation part and how to make it all link together. Since I have multiple events and sometimes at the same time, I want to see what would be the best way to configure it.

Not sure if this would be the correct path but doing a binary_sensor for each “Location” and than would trigger depending with one matches, would i than add an offset of 1 hour to make sure it turns on one hour before?

Anyone can help me with this issue? and how to to properly configure it!

The automation trigger variables that were linked in the above post can be used in automations. So you do ot need to create binary sensors for that.

When you use an event trigger for calendar events, those variables are available in the automation. So you can use conditions to check for certain things in the calendar item, and use the values for actions, such as notifications.

This won’t work however for events in the future. For that you need something like a time based trigger, get the calendar events for that day and loop over them to see what is coming up. It would require quite some templating skills and work to get it right, and more information on what you plan to do.

2 Likes

Thank you Edwin, would this make it easier i just make any upcoming calendar event will turn on AC one hour before Start Time and then turn off at the event end time? I feel this might be much simpler to accomplish.

Calendar events are pretty easy to use as triggers if you use the start- and endtimes to turn things on and off. It gets harder when you have overlapping events, so making a specific calendar for it may be smart.

Looking at the events, I did see they have a way to trigger ahead of time. The developer fortunately added support for it. So I was premature in my answer. You can put in a negative offset in the event to trigger early.

To experiment, I created a calendar and an automation. If I put one or more entity ids in the calendar item, it will turn those entities on and off with the event. Maybe that will give you some inspiration and an example on how you can use the events:

alias: Entities calendar turn on/off
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "0:0:0"
    entity_id: calendar.turn_entities_on_off
    id: "on"
  - platform: calendar
    event: end
    offset: "0:0:0"
    entity_id: calendar.turn_entities_on_off
    id: "off"
condition: []
action:
  - service: homeassistant.turn_{{trigger.id}}
    data_template:
      entity_id: >-
        {{ ((trigger.calendar_event.summary ~ ' ' ~
        trigger.calendar_event.description) | replace(',',' ') | replace(';','
        ') | replace('\'',' ') ).split() |
        select('search','^[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+$') | list }}
mode: single

Sorry I am still new to the whole automations and coding, can you give me a breakdown what the data_template is looking for like a certain trigger word in the event? or is just looking for the next upcoming event? Thank you again for replying back and helping me with this situation. Also i know you had said for overlapping events it gets harder (would this be possible to setup or is this something could not be done due to the way it reads the calendar?

Also how would i make it know which device to turn on based on the next upcoming event? Like if i have several ac units and each Event location is based on the ac unit that i need it to turn on?

It is looking for anything that looks like an entity id in the calendar item text. It is removing all separators like , or ; and replacing them with spaces, splitting it up along the spaces, checking for everyting that has the format of an entity id (a domain, a dot and a name) and converting that to a list.

The event is already known from the trigger. The details are in fields like trigger.calendar_event.summary and trigger.calendar_event.description. The documentation for that was already posted before in this thread: