Get timestamp from when Sensor last showed 'on'

Good day,

I’m trying to understand Templating a bit better but I’ve stumbled across a bit of a stumbling stone for me.

I want to do an automation that calls a Service if the door is opened under the condition, that that 3 motion sensors showed a certrain state AFTER the door was opened (and closed).

For this I’m trying to compare timestamps.
The door is my trigger. After that I’m setting a Condition as Template where I want to compare the timestamps. Problem is, I know I can compare last_changed

{{ as_timestamp(states.binary_sensor.Sensor1.last_changed)
 < as_timestamp(states.binary_sensor.Sensor2.last_changed) }}

but this is not what I want or need. I need to specifically get the timestamp for when the state changed to on.

What am I missing? Could someone show me an example please or hint me a better way to do this?

You can’t get past states from templates. You’ll have to write an automation that populates an input_datetime. Basically, the automation will trigger when the sensor goes on and it will store the current time in a input_datetime.

Well I almost thought so. I had hoped there is another way but this will do the trick I suppose.
Thank you!