@ Riva when the PE beam is broken the relay contacts change state until the beam is unbroken (for the use of a better word). Usually it is momentary as people & vehicles pass thru it, but occasionally a vehicle parks in front of it which means the contacts stay closed / open. I can't remember which way it is wired.
If the relay state stays the same till the beam is unbroken then use a flag variable that is set when you activate the sounder for 1 second and does not reset until beam is unbroken. After your 5 minutes have passed if the flag is still set and the beam is still broken then don't sound again.