Minimum time between Parallel Automations

Is there a minimum time between automation triggers? I have a few automations that I’ve noticed that don’t trigger ( even on parallel mode) repeatedly if the triggers are in close succession.

No, there is no minimum time. I just did a test using two identical triggers in the same automation, and setting the model to parallel. The two runs of that automation had a start time within 1 millisecond of each other.

First trace:

    "timestamp": {
      "start": "2024-11-22T03:09:33.248768+00:00",
      "finish": "2024-11-22T03:09:38.253104+00:00"
    },

Second trace:

    "timestamp": {
      "start": "2024-11-22T03:09:33.249597+00:00",
      "finish": "2024-11-22T03:09:38.255450+00:00"
    },

You probably have something else going on. Post the YAML from the automation, or at least the triggers and conditions.

This is one of them that doesn’t seem trigger after the first one. The entity triggers are all disabled. it is the template triggers further down that are actually being used. I’m using a template sensor to detect when new lights with a circadian label turns on, then it runs the circadian macros. The sensors themselves I can see update immediately and correctly. However, if several lights turn on at the same time, like if a light group switches on, only 1 actually triggers the automation. I thought about adding a slight delay to the sensor so it captures all lights at once, but If I don’t have to, I’d rather not to minimize jarring bright light in the middle of the night when I want dark, or dark lights when I need them on full.

alias: Circadian New light
description: >-
  Triggers when a new light turns on and the "Circadian Loop" automation is
  already running.
triggers:
  - trigger: state
    entity_id:
      - light.living_room_light_1_light
      - light.living_room_light_2_light_2
      - light.living_room_light_3_light_3
      - light.living_room_window_light
      - light.tv_light
    from: "off"
    to: "on"
    alias: Off to On Trigger
    enabled: false
  - trigger: state
    entity_id:
      - light.living_room_light_1_light
      - light.living_room_light_2_light_2
      - light.living_room_light_3_light_3
      - light.living_room_window_light
      - light.tv_light
    from: unavailable
    to: "on"
    alias: Unavailable to On Trigger
    enabled: false
  - trigger: state
    entity_id:
      - light.living_room_light_1_light
      - light.living_room_light_2_light_2
      - light.living_room_light_3_light_3
      - light.living_room_window_light
      - light.tv_light
    from: unknown
    to: "on"
    alias: Unknown to On Trigger
    enabled: false
  - alias: White New Lights
    trigger: template
    value_template: >-
      {% if int(states('sensor.new_white_circadian_light')) >
      state_attr('sensor.new_white_circadian_light','last_state') %}

      {{"true"}}

      {% else %}

      {{"false"}}

      {% endif %}
    id: White
  - alias: RGB New Lights
    trigger: template
    value_template: |-
      {% if states('sensor.new_rgb_circadian_light') == 'true' %}
      {{"true"}}
      {% else %}
      {{"false"}}
      {% endif %}
    id: RGB
  - alias: RGBWW New Lights
    trigger: template
    value_template: |-
      {% if states('sensor.new_rgbww_circadian_light') == 'true' %}
      {{"true"}}
      {% else %}
      {{"false"}}
      {% endif %}
    id: RGBWW
conditions:
  - condition: state
    entity_id: input_boolean.circadian_status
    state: "on"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - White
        sequence:
          - action: notify.persistent_notification
            metadata: {}
            data:
              message: "{{state_attr(trigger.entity_id, 'new_lights') }} "
          - action: light.turn_on
            metadata: {}
            data:
              kelvin: >-
                {%- from 'light_templates.jinja' import Circadian
                -%}{{Circadian('white', 'color')}}
              brightness_pct: >-
                {%- from 'light_templates.jinja' import Circadian
                -%}{{int(Circadian('white','bright'))}}
            target:
              entity_id: |
                {{state_attr(trigger.entity_id, 'new_lights') }} 
            alias: White Light On
            enabled: false
      - conditions:
          - condition: trigger
            id:
              - RGB
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              rgb_color: >-
                {%- from 'light_templates.jinja' import Circadian
                -%}{{Circadian('rgb', 'color')}}
              brightness_pct: >-
                {%- from 'light_templates.jinja' import Circadian
                -%}{{int(Circadian('RGB','bright'))}}
            target:
              entity_id: >
                {{ label_entities('Circadian RGB')  | select('is_state', 'on') |
                reject('search', 'power_on')  | reject('search', 'lights') |
                list }}
            alias: RGB Light On
      - conditions:
          - condition: trigger
            id:
              - RGBWW
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              rgbww_color: >-
                {%- from 'light_templates.jinja' import Circadian
                -%}{{Circadian('RGBWW', 'color')}}
              brightness_pct: >-
                {%- from 'light_templates.jinja' import Circadian
                -%}{{int(Circadian('RGBWW','bright'))}}
            target:
              entity_id: >
                {{ label_entities('Circadian RGBWW')  | select('is_state', 'on')
                | reject('search', 'power_on')  | reject('search', 'lights') |
                list }}
            alias: RGBWW Light On
mode: parallel
max: 20

Can you give an example of what entities or templates you are expecting to trigger this automation in rapid succession?

Edit: ignore this. Your description is fine.

I’ll take a stab in the dark that you’re having problems with the “White” trigger. Besides being unnecessarily verbose, that template won’t keep triggering if the state of sensor.new_white_circadian_light successively increases. Templates will only trigger when they transition from false to true and if that entity keeps changing to a larger number, the template will continue to render true and thus won’t fire again after the first increase. Since I don’t understand the purpose of this automation, I can’t be certain that is what you want. But if it is, here’s what I would suggest:

alias: Circadian New light
description: >-
  Triggers when a new light turns on and the "Circadian Loop" automation is
  already running.
triggers:
  - alias: White New Lights
    trigger: state
    entity_id: 'sensor.new_white_circadian_light'
    id: White
  - alias: RGB New Lights
    trigger: state
    entity_id: sensor.new_rgb_circadian_light
    to: 'true'
    id: RGB
  - alias: RGBWW New Lights
    trigger: state
    entity_id: sensor.new_rgbww_circadian_light
    to: 'true'
    id: RGBWW
conditions:
  - condition: state
    entity_id: input_boolean.circadian_status
    state: "on"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - White
          - condition: template
            value_template: "{{ trigger.to_state.state | int(0) > trigger.from_state.state | int(999) }}"
        sequence: 
<... continue as originally posted ...>

Also in your notifications you’ll need to replace each instance of trigger.entity_id with trigger.to_state.entity_id since I replaced your template triggers with state triggers.

I actually had the template as a true/false state but changed it so I could see the state history to make sure it wasn’tdet issue with the template sensors; I just never changed it back since it caused the same issue and I can use it for debugging.

But I had not considered the false to true scenario and I’m not sure I tried slowly turning on lights to test that. I guess a sensor state set to either true or false would also give the same results also; if it was already true, it most likely won’t trigger again. I’m on my phone and not at home right now, so I’ll have to try testing tomorrow. But thanks, I think you may be on to something.

FYI, the purpose is I have a circadian rhythm automation that runs on a loop if any lights that I want to use it are ‘on’ and changes all those lights at once on a 5 min interval. Since I only want a single instance of that automation running, it doesn’t detect new lights turning ‘on’ until the next loop.

I am using this automation to detect lights that turn on within that 5 min window and run the circadian macro once until the next loop on the other automation takes over. I’m trying to do this all dynamically so I only need to label new lights and they are automatically added to the automations instead of having a crap load of triggers within the automations, or a bunch of automations.

I’m open to suggestions if you have any to streamlining it.

If I’m thinking about this correctly, you’d want an automation that has two triggers

  • Time pattern for every 5 minutes
  • When any of the “circadian-labeled” lights turns ON.

In the actions, you’d want a choose block:

  • If the automation was triggered by a single light turning ON, then run the circadian macro on that light
  • If the automation was triggered by the time pattern trigger, then run the circadian macros on every light that is ON

To do this, I would create a template sensor that has an attribute (let’s call it circadian_lights_turned_on) which is a list of every circadian light entity_id that is ON. And the state of that template sensor could simply be the count of those lights. So then in your automation, you could use the state of that sensor for the second trigger I listed above. And when you run the automation on every light that is ON, you can get that list of lights from the attribute in that sensor (which would be trigger.to_state.attributes.circadian_lights_turned_on)

My Man (or Woman)! I think this is exactly what was happening. Funny enough, it worked if there was enough time between the successions, just not if they were quick. I moved the value template to conditions and now it fires as it should. Thank you.

Lol. That is almost exactly how I started so I’m glad someone else has the same reasoning. I broke it into 2 automations because I didn’t somehow want 2 time loops running, so I wanted that on single mode and the new lights on parallel mode. Silly reasoning, maybe, but still.

I also created a second template sensor, the one that you saw in the automation, that strips out the new light entity because, from what I read, it would be more robust than doing it within the automation itself (I couldn’t send these last night since android sucks at CodeMirror):

template:
  - sensor:
      - name: circadian_white_list
        unique_id: circadian_white_list
        state: "{{ int(label_entities('Circadian White')  | select('is_state', 'on') | reject('search', 'power_on')  | reject('search', 'lights') | list | count)}}"
        attributes:
          lights: "{{ label_entities('Circadian White')  | select('is_state', 'on') | reject('search', 'power_on')  | reject('search', 'lights') | list }}"
  - trigger:
      - platform: state
        entity_id: sensor.circadian_white_list
    sensor:
      - unique_id: new_circadian_white
        name: "New White Circadian Light"
        state: >
             {{trigger.to_state.state}}
        attributes: 
          new_lights: >
            {% if int(trigger.from_state.state) < int(trigger.to_state.state) %}
            {{ trigger.to_state.attributes.lights|reject('in',trigger.from_state.attributes.lights) | list }}
            {% endif %}
          last_state: "{{trigger.from_state.state }}"

So again, I appreciate the help. Thank You.