Google Calendar search for events beginning with "holidays"

Hi there, I am just about to add some sensors with the Google Calendar integration to be able to use them for my automations. Not a big deal at all but there’s a detail working out as a showstopper:

I want to use the search option to find out whether or not it’s holidays. So I have to search for calendar events starting with “holidays” so my sensor gets triggered when the event is “summerholidays” or “winterholidays” or any other “…holidays”.

As far as I could find out there’s no wildcard to be used in yaml, is there? So are there any other options than creating a specific sensor for every kind of holidays?

- cal_id: ***@group.calendar.google.com
  entities:
  - device_id: holidays
    ignore_availability: true
    name: Holidays
    track: true
    search: holidays

As there’s obviously no such option I solved it by creating a new calendar with holidays only and omitted the search option. So the sensor will turn “on” regardless of the event name.

Would be nice to be able to search for events beginning with or ending with a particular string though!

I agree! I want certain events triggered according to whether my husband is on 1st (call) versus Post 1st. Searching for 1st obviously brings up both. I haven’t been able to figure out a way to separate the two. Same with 4th and Post 4th. I don’t enter the calendar items myself, they come from an external source, otherwise I’d be able to change them.

@Zahnweh and @dlthompson06 you can do automations using triggers and templates now using automations instead of yaml.

Also see the links to automations in the calendar integration for all calendars. The yaml stuff is not flexible, and something I’d suggest moving away from.

As @allenporter wrote it can be done with the Calendar trigger event.
The template condition allows to search for pattern within your calendar entry decription / text more flexible.

The only downside of the calendar trigger automation:
A manual run does always execute the action as the trigger states are not avalable while triggering manually.

You can also use a template sensor to make a binary sensor from the event if you need the state persisted somewhere.

Can you share the automations for on and off please?

Sure.
Automation: Set Mode - School Vacation ON

alias: Set Mode - School Vacation ON
description: based on Google Calendar Bastian
trigger:
  - platform: calendar
    event: start
    offset: "-0:0:0"
    entity_id: calendar.bastian_kunz_googlemail_com
condition:
  - condition: template
    value_template: "{{ 'ferien' in trigger.calendar_event.summary }}"
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id:
        - input_boolean.school_vacation
mode: queued
max: 10

Automation: Set Mode - School Vacation OFF

alias: Set Mode - School Vacation OFF
description: based on Google Calendar Bastian
trigger:
  - platform: calendar
    event: end
    offset: "-0:0:0"
    entity_id: calendar.bastian_kunz_googlemail_com
condition:
  - condition: template
    value_template: "{{ 'ferien' in trigger.calendar_event.summary }}"
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id:
        - input_boolean.school_vacation
mode: queued
max: 10
1 Like

Thanks @allenporter & @Bastian007. I’ll stick to my solution though. Time has shown that it’s nice to be able to type any event name in the holiday calendar and have the sensor triggered regardles of what the name is. Often it’s not some kind of holiday but maybe just an ordinary off-day.

On your code, what does the mode queued actually mean and do? I am running into an issue with overlapping events. When there are overlapping events it seems the summary trigger stores the first event information and I can’t get any other event summary in the trigger while the first event is active. I thought the mode of queue or parallel was supposed to allow for overlapping events to trigger different actions. Is this not correct?

Possibly not perfect answer on this topics, but could give some ideas.
Let say I have a facility/house that have separate parts/room that each have have there own heatpump.
This house is open for rental, complete house or just single room.
I solved this with a google calendar, with events. The subject textstring in this events include formatet info about each room. For each heatpump/room I made one template sensor. Those sensors gives with predefined calendar trigger offset attributes a triggers at -3h, -2h. -1h, start and end of event. So one single event in google calendar will controll pre-heat, heat and close down of all of the heatpumps in this house.
There are however limitation in writing template sensors like no support for trigger conditions, so all sensors, one per heatpump is trggered, but only specific one reponsible for one heatpump is updated (new state) based on matchning attributes in Subject. This is done by some templating in state and attributes setting, and use of "trigger"and “this” object.
Possible this could give some ideas in be prepared for your holidays/vacation.