#Aggregate multiple all day calendar events into a single trigger?

1 messages · Page 1 of 1 (latest)

peak echo
#

My local trash collection gives me several calendar events each week: one for each trash type. I'd like to setup a calendar automation to notify me, but preferably not four notifications, but rather one notification containing all four items for the collection.

I just tried a calendar trigger and it's firing for each trash type (one trigger per event). Is there a way to collect all these triggers and turn them into a single notification containing all of them?

A clarification: they're all on the same day and are all "all day" calendar events. So for example, tomorrow I have "black bin", "compost" and "yard trimmings". Next week it'll be "blue bin", "garbage", "compost" and "yard trimmings". Occasionally we get a fifth like "pumpkin collection"

remote tinsel
#

You would leave the trigger as it is, then use conditions to prevent more than one trigger per day, and use the calendar.get_events action with some templating to query the calendar and merge all the day's events into a single message.

peak echo
#

how would i prevent more than one trigger a day? Currently all events fire simultaneously afaict?

remote tinsel
#

There are various ways to throttle an automation.

The most rudimentary is to add a delay at the end of your actions block and make sure the automation's mode is set to single. That will be enough to prevent concurrent Calendar events from causing multiple runs of the automation. This method realy should only be used for relatively short time spans up to a couple minutes.

Another option is the following condition, which can be adjusted to cover any length of time:

conditions:
  - alias: Check if it has been at least 30 minutes since this automation's action block was last run.
    condition: template
    value_template: |  
      {% set last_run = this.attributes.last_triggered|default(as_datetime(0),1) %}
      {{ now() >=  last_run + timedelta(minutes = 30) }}
peak echo
#

hmm ok

#

what's interesting, now i've added actions. it's only doing the action once. even though there's 4 triggers.

#

is that because "single" mode?

#

Stopped because only a single execution is allowed at November 5, 2025 at 4:37:00 PM (runtime: 0.00 seconds)

#

ah yes it is

remote tinsel
#

It's because it's in single mode and the action sequence takes long enough that the first run of the automation is still in process when the last trigger fires.

peak echo
#

as i said, they all seem to fire "simultaneously"

#

so yeah, "single" is preventing the multiple firings from occuring! nice

#

Finished at November 5, 2025 at 4:37:00 PM (runtime: 0.01 seconds)

#

the one that does fire takes 10 milliseconds heh

remote tinsel
#

The degree to how simultaneous they are can be affected by how fast and how busy your system is at that particular moment. So adding a couple second delay can be a useful trick.

peak echo
#

my system is pretty fast and not very busy

#

but anyway, single works

crude flame
#

I don't know if this example of automation can help to your goal.

triggers:
  # time to send the notification
  - at: "08:00:00"
    trigger: time
actions:
  - target:
      entity_id: calendar.name_of_your_calendar
    data:
      start_date_time: "{{ now().replace(hour=0, minute=0, second=0).isoformat() }}"
      end_date_time: "{{ now().replace(hour=23, minute=59, second=59).isoformat() }}"
    # Event list
    response_variable: day_events
    action: calendar.get_events
  - condition: template
    # If no events, no notification
    value_template: "{{ day_events.events | count > 0 }}"
  - data:
      title: Today's Events
      message: |
        {% set events = day_events.events %}
        {% set count = events | count %}
        You have {{ count }} events scheduled for today:
        # This creates a bulleted list of all events
        {% for event in events %}
        - {{ event.summary }}
        {% endfor %}
    action: notify.mobile_app_your_phone
mode: queued```
steady sentinel
#

I was going to suggest the same approach, ie. don't trigger on events, but trigger daily and then verify events exists. calendar.get_events uses a target selector, allowing you to pick multiple calendar entities.

#

I have similar setup, and as a bonus, I throw the resulting JSON into a Gemini prompt, asking it for a nice summary instead of coding the exact output format.

#

I throw in a location from my mobile app and ask it to calculate the wake up time according to traffic and the time needed to get to the first event next day 😅