Template with timer function

I have a camera of which I want to show its stream in HA. It triggers on the camera’s built-in PIR. I can get this to work but when something/someone is moving in fornt of the camaera, the PIR-signal goes on and off very rapidly. Maybe even 10x per second. So the picture in HA also goes on and off. I would like this to stay steady for some seconds.
How could I do this?

Adrie de Regt

Use the “delay_off” attribute in the binary_sensor template.