How to circumvent the requirement for triggers in automations?

I’m coming from smartthings where i can simply create automations based on “if all the following conditions are met”.
How do i do this in home assistant? Can i simply use “if light is on” as a trigger? And it will keep waiting for conditions to become valid for the automation to execute?

I for example use two sensors in every space in my house/garden. a camera with person detection using frigate, but also a normal motion sensor. If no person is detected, no sound is detected, no motion is detected, all for around a minute, then turn lights off. If i use any of the above as trigger, then i’m afraid that the minute has past and the other sensors did not reach a exact minute yet, and therefore the automation will never execute.

Thanks for assistance!

Yes, you can use the light being on as a trigger then use wait templates (or wait-for-trigger) for have the automation only continue based on other things. This would be useful if the ‘condition’ (but using the normal/actual condition method) is potentially not in the required state when the trigger fires.

There are other ways of doing this but from what I think I understand you are trying to acheive, the above will work.

is it possible to use that without code?

Set up a trigger (which can include a for: timer) and a matching condition for each of your criteria.

That will do what you want: evaluate when any of the things become true but run the action only if all are true.

1 Like

I have some logic I use that might work for your use case. I have a trigger for each of the conditions (in your case one each for person detection changed to off, sound detection changed to off, and motion detection changed to off). Then in the conditions I check to make sure all of the trigger activities are in the state I want (i.e. no person, no sound, no motion). Then I have the action (i.e. turn off the light). That way, any of the detections changing to off will trigger the automation, but the action will only happen if all the detectors are off.

The only other thing to consider is that you need to change the mode of the automation to restart or queued so that the automation can run multiple times even if one of the other triggers goes off while the automation is running.

Here’s an example from my setup:

alias: Bedroom Fan On
description: ""
  - platform: numeric_state
    entity_id: sensor.bedroom_temperature
      hours: 0
      minutes: "{{ states('input_number.temp_delay_minutes')|int }}"
      seconds: "{{ states('input_number.temp_delay_secs')|int }}"
    above: input_number.bedroom_fan_threshold
    id: temperature
  - platform: state
      - binary_sensor.main_bedroom_occupied
    to: "on"
    from: "off"
  - condition: numeric_state
    entity_id: sensor.bedroom_temperature
    above: input_number.bedroom_fan_threshold
  - condition: state
    entity_id: binary_sensor.main_bedroom_occupied
    state: "on"
  - type: turn_on
    device_id: dfa365beeadbbf859376aff4ee1b1c90
    entity_id: 15404c4a6c348bb85b2ea6a5382cedc9
    domain: fan
mode: restart
1 Like

So, multiple triggers of all those sensors, and put the 1min timer in the trigger, while in the conditions the timers are zero/immediate?
Sounds interesting…Im not sure what you mean wth the automation modes, and reading the wiki also doesn’t make me much wiser.

1 Like

This is your core difference from St. Multiple triggers in st routines are… Let’s say difficult? Cumbersome? *cough next to impossible *cough in SmartThings routines and the ST editor.

You can have as many triggers as you want in the automation, and every time it fires it reviews all the conditions for true.

Thats why automation mode matters here what if three things trigger at once?

Info on automation modes:

One edit one other hint for someone coming for ST- try to avoid device triggers or referring to devices in actions instead state triggers and actions that refer to entity_ids wherever possible - It will make your automation much easier to maintain of you ever swap devices.

By default once an automation starts if something triggers it again and it isn’t finished, it just ignores the trigger. That might cause the automation action not to run depending on the timing of the things.

restart mode will stop the automation and restart it using the new trigger. queued mode will hold on to the second call of the automation and run it after the first one is done. Either of those will likely help you avoid any unexpected outcomes (i.e. you swear all the sensors are registering off but the light is still on).

1 Like

the problem you will have with all of the suggested “wait” type conditions is that if the automation is “waiting” for conditions to be satisfied after the trigger fires and you restart HA or reload automations then the automation that is “waiting” will be cancelled without completing the actions.

That might be OK for short duration “waits” (my limit is no more than 5 minutes since the odds of restarting in that 5 minutes is usually minimal) or if it isn’t critical that the automation actions are performed.

otherwise you need to harden the automation against failure.

but either way you will always need a trigger to start an automation. There is no getting around it since that’s just the way the HA automation system works.

1 Like

Wouldn’t it be a (crazy?) idea to make a virtual switch, turn it on and off every 1 sec, and use that for the trigger? (if virtual switch turned on). then it constantly verifies the set conditions, and it basically becomes a “if all conditions are met, then do this”?
basically removing the trigger?

Yes it would be a crazy idea.

You’re just creating extra constructs to do the same thing a timer would do.
Dont use a running timer for things that should be triggers (triggers are much easier for your system than dealing with a running loop all the time)

This falls into the category of:

“Tell me you don’t understand how automations work without explicitly telling me you don’t know how automations work.”


Automation Basics


but it seems from the discussion above it has it’s limits as well, and are we talking a lot of strain on the system? It’s probably just confusing for me, i should dive into some youtube videos about this specific problem. (multiple sensors, multiple lights controlled)

The title of this topic implies a fundamental misunderstanding of how Home Assistant’s automations work. If the documentation link I posted above doesn’t help to clarify it then, by all means, find a video that does.


Yes, without getting into detail, it’s basically an order(s?) of magnitude over what a trigger needs because at its core HA is just a big old state engine and operates on triggers

So trying to do anything else is forcing it to behave outside how it’s designed. You create a timer, you now have a thread keeping track while with a trigger you have none (ok you’re inside the main state engine loop but… You didn’t add anything to make it happen) you’re talking about not only adding a timer but extra constructs to kick them. Not a good idea.

We will not be assimilated - Not Locutus

I think I must be missing something, but a single template trigger with all 3 conditions AND together, and a for 1 minute would surely do the trick?

you would then have two automations to accomplish the same end result.

one automation turning on and off the virtual switch (the only way I know to accomplish that would be using a time pattern trigger in an automation) and the the second automation to trigger off the virtual switch changing states.

if you REALLY wanted to go down the “trigger an automation every second” route just skip the virtual switch theory and use the every second time pattern trigger in the second automation. then you will only have one very inefficient automation instead of two.

Or better yet…

Discard your preconceived notions about how automations are supposed to work based on your previous system and use them in the way your current HA system works.