Motion Sensor - Create Scene - NodeRed

Hello,

i have a simple node red automation that will create a scene of some light and set the brightness of a light on motion. If the motion is gone the created scene will be activated again. (The motion sensor has a detection interval of 180sec). So far so good.

But there is one problem and i don´t know how to solve this. If the detection interval was reached the created scene is activated even someone is still “there”. So i want something like a loop to check if the sensor detect new motion and wait before activate the scene without creating a new scene.