State trigger with multiple "for:" values

Hi All,

I have an example of an automation which needs to trigger after

  • 30 seconds
  • 45 seconds
  • 1 minute 30 seconds
  • 1 minute 40 seconds
    after a specific state change.

At the moment my triggers look like:

      - id: 'timer_1'
        platform: state
        entity_id: binary_sensor.backup_jobs_bareos_refresh
        to: 'on'
       for: '00:00:30'
      - id: 'timer_2'
        platform: state
        entity_id: binary_sensor.backup_jobs_bareos_refresh
        to: 'on'
        for: '00:00:40'
      - id: 'timer_3'
        platform: state
        entity_id: binary_sensor.backup_jobs_bareos_refresh
        to: 'on'
        for: '00:01:30'
      - id: 'timer_4'
        platform: state
        entity_id: binary_sensor.backup_jobs_bareos_refresh
        to: 'on'
        for: '00:01:40'

Is there some way to consolidate this like:

      - id: 'timers'
        platform: state
        entity_id: binary_sensor.backup_jobs_bareos_refresh
        to: 'on'
        for: 
          - '00:00:30'
          - '00:00:40'
          - '00:01:30'
          - '00:01:40'

No. for does not accept lists.

has this been changed? as I need to do something simular ie repeat every minute until alarm is resolved

No. Couple of options:

  • Use Repeat Until in the action with a one minute delay in the loop
  • Trigger from the thing and from a minute since the last automation run.

Example of the latter:

trigger:
  - platform: state
    entity_id: binary_sensor.alarm
    to: "on"
  - platform: state
    entity_id: automation.id_of_this_automation
    attribute: last_triggered
    for: "00:01:00"
condition:
  - condition: state
    entity_id: binary_sensor.alarm
    state: "on"
action:
  - YOUR ACTION HERE

Note that last_triggered is a bit of a misnomer: it holds the time that the action block was last executed.

The other option if your action is only a notification is to use an alert:

Thanks for this nice solutions!
Still hoping that ‘for’ will support a list of times in the future