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.