Automation condition for Multiple all day events in Local Calendar?

I agree it should work as is.

That should not be necessary… Just remember that, when using until, the repeat sequence will always run at least once. If you want to avoid that, you should switch to a while based repeat.


I don’t know if you’re interested in an alternative method, but the following creates a combined message for two-bin weeks as well as supplying binary sensor entities that can be useful for dashboard cards:

Step 1: Set up trigger-based template sensors for the different bin options

Template sensors
template:
  - trigger:
    - platform: calendar
      event: start
      offset: '-6:00:00'
      entity_id: calendar.calendar
      id: 'on'
    - platform: calendar
      event: end
      offset: '00:05:00'
      entity_id: calendar.calendar
      id: 'off'
    binary_sensor:
    - name: Brown Bin
      state: >
        {% set current = this.state | default('off') %}
        {% if trigger.calendar_event.summary is search("Brown bin collection") %}
        {{ trigger.id }}{% else %}{{ current }}{% endif %}
    - name: Blue Bin
      state: >
        {% set current = this.state | default('off') %}
        {% if trigger.calendar_event.summary is search("Blue bin collection") %}
        {{ trigger.id }}{% else %}{{ current }}{% endif %}
    - name: Black Bin
      state: >
        {% set current = this.state | default('off') %}
        {% if trigger.calendar_event.summary is search("Black bin collection") %}
        {{ trigger.id }}{% else %}{{ current }}{% endif %}

Step 2: Set up Automation

alias: Bin collection
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "-3:00:00"
    entity_id: calendar.calendar
    variables:
      blue_or_black: "{{ trigger.calendar_event.summary in ['Blue bin collection', 'Black bin collection'] }}"
condition:
  - condition: template
    value_template: "{{ blue_or_black}}"
action:
  - variables:
      bins_on: >
        {{ ['binary_sensor.blue_bin', 'binary_sensor.black_bin', 'binary_sensor.brown_bin']
        | select('is_state', 'on')
        | map('state_attr', 'friendly_name') 
        | map('replace', ' Bin', '') | map('lower') | list }}
      message: >
        It is Bin day tomorrow.  It is {{ bins_on | join(' and ' if
        bins_on|count > 1 else '') }} bin day on {{
        (trigger.calendar_event.start | as_datetime).strftime("%A, %D") }}
  - service: notify.mobile_app
    data:
      message: " {{ message }}"
      data:
        color: " {{ iif('blue' in bins_on, 'blue', 'black') }} "
        channel: Bin collection
        tag: bin-collection
        alert_once: true
        sticky: true
  - repeat:
      until:
        - or:
            - condition: state
              entity_id: binary_sensor.front_door_contact_sensor
              state: 'on'
            - condition: template
              value_template: "{{ repeat.index == 30 }}"
            - condition: state
              entity_id: input_boolean.emergency_switch_helper
              state: "on"
      sequence:
        - service: notify.living_room_tv
          data:
            message: "{{ message }}"
          enabled: true
        - delay: 10
mode: single
1 Like