Help with Infrared Motion Sensor with Servo

I'm working on an project on a container.

I attached an Infrared Motion Sensor to the lid of the container and a servo to open the lid.

The concept is when the Infrared Motion Sensor detects movement, the servo will turn and open the lid for a few seconds.

But now I got a problem,
When I wave my hand above the sensor, the sensor detects motion and the lid will open, but when the lid is closing
The sensor will detect movement again and the lid opens again without my hand waving
And the lid just keep opening and closing endlessly

So how can I make it so that only when my hand waves, the lid will open
Without the lid closing and opening endlessly

This is the code.
But i just can't wrap my head around how to make this work.
I need some assistance with the code

#include <Servo.h>
Servo servo1;

void setup() {
  // put your setup code here, to run once:
  servo1.attach(8);
  pinMode(10,INPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly
  int sensorValue = digitalRead(10);

  if (sensorValue == 1) {
    servo1.write (180) ;
  }
  else {
    servo1.write (0) ;
  }
}

Add a delay after the lid has been closed. Get the time when after closing the sensor fires and deactivates again. Then discard any sensor input within that interval. Extend the interval while the sensor still signals movement. See the BlinkWithoutDelay example for handling time intervals.

I'm quite new

So how do i get the time when the sensor fires and deactivates
And how to discard the sensor input

I've read the BlinkWithoutDelay
But I'm still confused

See how BlinkWithoutDelay gets the current time, stores it, and determines when a time interval has elapsed.

You get the current time when the lid closes, then the time when the sensor triggers (wrong) and resets again. Calculate the difference for later use as the interval when nothing shall happen after the lid closes.