Sequential triggers

I am trying to figure out how to code for sequential triggers. I can think of a way to achieve it using input_booleans but figure there must be a simpler / more elegant way to do it.

What I am trying to do is:
trigger 1 occurs
automation is semi-triggered, awaiting the next trigger
then wait until second trigger occurs to perform the action as long as its conditions are met. This action must only commence if the triggers occurred in the correct order and within a predetermined time-frame.
Also, I want this to only occur when that sequence happens for the first time that day, but that part I know how to achieve, even if it isn’t the best way…

I haven’t yet worked out my exact use-case yet because I wanted to see if such a thing can be done first (without diving into AppDaemon or something)

Does anyone have anything as an example that follows a similar sort of logic?

My suggestion:

Have automation #1 (with trigger 1) turn on 2 automations and turn itself off:

automation #2 that tests for trigger 2. and automation #3 that turns off automation 2 and turns on automation 1 again if too much time elapsed

1 Like

As well as chaining automations, you can use wait_template in the actions, as well as testing conditions. That would allow you to “chain” triggers.

For once a day, the best solution is to have it turn itself off when it runs, and another automation to turn it on at (say) midnight.

3 Likes

so this is under ‘scripts’ in the docs but can be used in a normal automation? It looks promising for what I want here. thanks.

yeah, thats how I was looking at doing it.

I’ve also started looking at AppDaemon but it seems a bit complicated for someone who has never programmed in Python before…

It’s under the scripts documentation because if you were to read the automation documentation when you get to the action page it tells you:

The action of an automation rule is what is being executed when a rule fires. The action part follows the script syntax which can be used to interact with anything via services or events.