Trigger automation by 2 different IR sensors

I would like to trigger an automation when 2 different IR sensors change status after each other like this:

binary_sensor.IR1 “on” (the sensor could go to off or not before next sensor is trigged)

No more then 20s

binary_sensor.IR2 “on”
Trigger the automation

The reason is that I would like to trigger our God morning automation if the IR outside the bedroom is on and then the IR sensor in the kitchen is trigged.

Somebody have any idea how this could be done?

Trigger on binary_sensor.IR2 “on” with the following condition:

  condition:
    condition: template 
    value_template: "{{  (as_timestamp(now()) - as_timestamp(state_attr('binary_sensor.IR1', 'last_changed'))) | int  < 20 }}"

This will ensure the actions only occur if binary_sensor.IR2 goes on within 20 seconds of binary_sensor.IR1 changing.

Great thanks, I will try that