Trigger automation only when a calendar event end isn't followed by another calendar event

I have an automation that opens my garage door whenever a child is on the way home from school. I would like to only do this if a kid doesn’t have an after-school activity on the calendar. Is there a way to check the source calendar for a “current” event after an offset triggers the automation?

alias: Open garage after school
description: ""
trigger:
  - platform: calendar
    event: end
    offset: "0:15:0"
    entity_id: calendar.child_1
  - platform: calendar
    event: end
    offset: "0:15:0"
    entity_id: calendar.child_2
condition:
  - condition: template
    value_template: "{{ 'School' in trigger.calendar_event.summary }}"

I’ve read suggestions of setting up a binary_sensor, but every example seems to be checking state of the triggering event or of some other entity. I haven’t quite figured out if I can do this based directly on the triggering event’s entity, or if I should split this up back into the two original automations for each kid separately, and I also don’t really know how I can get the “next” event or the “current” event based on the current time after the offset triggers the automation (event ends at 2:30, trigger is at 2:45, check for a separate event currently going at 2:45 on the same calendar).

So…any suggestions?

You didn’t specify whether after school events will have a particular value that is searchable or how far in the future needs to be checked, but the general method would be something like the following:

alias: Open garage after school
description: ""
trigger:
  - platform: calendar
    event: end
    offset: "0:15:0"
    entity_id: calendar.child_1
    id: child_1
  - platform: calendar
    event: end
    offset: "0:15:0"
    entity_id: calendar.child_2
    id: child_2
condition:
  - condition: template
    value_template: "{{ 'School' in trigger.calendar_event.summary }}"
action:
  - service: calendar.list_events
    data:
      duration:
        hours: 3
        minutes: 0
        seconds: 0
    target:
      entity_id: calendar.{{ trigger.id }}
    response_variable: agenda
  - condition: template
    value_template: >-
      {{ agenda.events | selectattr('summary', 'search', 'after school') | list | count == 0 }}
  - # WHATEVER YOU DO TO OPEN THE GARAGE
mode: single

I think that makes sense. I apologize if I wasn’t clear in my original message, but I’m looking specifically to see if there is an active event at the time the automation is triggered. For instance, if the “School” event ends at 2:30, with a 15 minute offset it would run at 2:45. I want to know specifically if there is an event currently ongoing at 2:45, but I think I should be able to get there from your example.

For a current event you could just check the state of the calendar entity. A calendar’s state will be ‘on’ if an event is currently happening.

alias: Open garage after school
description: ""
trigger:
  - platform: calendar
    event: end
    offset: "0:15:0"
    entity_id: calendar.child_1
    id: child_1
  - platform: calendar
    event: end
    offset: "0:15:0"
    entity_id: calendar.child_2
    id: child_2
condition:
  - condition: template
    value_template: "{{ 'School' in trigger.calendar_event.summary }}"
  - condition: template
    value_template: "{{ is_state( 'calendar.'~ trigger.id, 'off') }}"
action:
  - # WHATEVER YOU DO TO OPEN THE GARAGE
mode: single

That’s even simpler. Thank you!