Strange results from a Calendar automation

I’m getting odd results from a calendar automation…

The calendar (not under my control) consists of bin collection entries. These are always set to midnight. My automation attempts to send a message 7 hours before the start of any entry in the calendar.

When only one calendar entry is present for a day then my automation works perfectly. When two bin entries (green bin and brown bin) are set for the same date then I get two messages, both for ‘green bin’. My wife gets four messages, all for ‘green bin’! We never see any messages for ‘brown bin’, which is the second entry on the list for that day.

I’ve set the automation mode to ‘queued’.

Can anyone please help me understand what I’m doing wrong, and how I might fix it?

alias: Bin Collection Notification
description: ""
triggers:
  - trigger: calendar
    entity_id: calendar.xxxx_metropolitan_borough_council
    event: start
    offset: "-7:0:0"
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: calendar.xxxx_metropolitan_borough_council
            attribute: message
            state: Green bin
        sequence:
          - parallel:
              - data:
                  message: Green Bin Tomorrow
                action: notify.mobile_me
              - action: notify.mobile_wife
                data:
                  message: Green Bin Tomorrow
      - conditions:
          - condition: state
            entity_id: calendar.xxxx_metropolitan_borough_council
            attribute: message
            state: Pink lid bin
        sequence:
          - parallel:
              - data:
                  message: Pink Lid Bin Tomorrow
                action: notify.mobile_me
              - action: notify.mobile_wife
                data:
                  message: Pink Lid Bin Tomorrow
      - conditions:
          - condition: state
            entity_id: calendar.xxxx_metropolitan_borough_council
            attribute: message
            state: Black bin
        sequence:
          - parallel:
              - data:
                  message: Black Bin Tomorrow
                action: notify.mobile_me
              - action: notify.mobile_wife
                data:
                  message: Black Bin Tomorrow
      - conditions:
          - condition: state
            entity_id: calendar.xxxx_metropolitan_borough_council
            attribute: message
            state: Brown bin
        sequence:
          - parallel:
              - data:
                  message: Brown Bin Tomorrow
                action: notify.mobile_me
              - action: notify.mobile_wife
                data:
                  message: Brown Bin Tomorrow
mode: queued
max: 10

Your conditions rely on the state of the calendar entity, which will only hold the data from the current or next upcoming event. If there are concurrent/overlapping events only one will be represented… this will not change until that event is over.

Instead you should use the values from the event that triggered the automation which are available in the trigger variable.

alias: Bin Collection Notification
description: ""
triggers:
  - trigger: calendar
    entity_id: calendar.xxxx_metropolitan_borough_council
    event: start
    offset: "-7:0:0"
conditions: []
actions:
  - action: notify.mobile_me
    data:
      message: "{{ trigger.calendar_event.summary | title }} Tomorrow"
  - action: notify.mobile_wife
    data:
      message: "{{ trigger.calendar_event.summary | title }} Tomorrow"
mode: queued
max: 10

Thank you so much. I would never have come up with this. Your solution is so much simpler than mine. And I’ve never got my head around those template things.

Where would I find the details to come up with ‘{{ trigger.calendar_event.summary | title }} Tomorrow’
I don’t see ‘title’ or ‘event_summary’ mentioned in the description of the calender in Developer Tools? I ask in order to become more self-sufficient.
(I see you covered this in your answer - thank you!)

(I’m still puzzled as to why I was getting the message twice and my wife getting it four times, but I’ll gloss over that now.)

Much appreciated.

Her receiving 4 messages is weird, 2 messages is to be expected. The automation above will still produce a message for each event. If you want to only receive 1 consolidated message, that is possible, but more complicated.

Yep, odd one that. I’ll wait to see that the next double event works as expected, then mark this as solved.