Door window sensor FGK-10x - pulse events

Hi i’ve connected a door sensor to the diode connections on a doorbell an hooked it up to openhab. Each time the doorbell is pressed i see up to 10 open close events posted. {i guess the diode is supposed to flash.} Anyhow’s what i’m trying to figure out how to execute a rule based on the first change only.

var SimpleDateFormat df
var String Timestamp
var Number cnt=0

rule "doorbell"
when

Item coStatus_DoorBell changed from “OPEN” to “CLOSED”

then

cnt=cnt+1
df = new SimpleDateFormat( “YYYY-MM-dd HH:mm:ss” )
Timestamp = df.format( new Date()

sendBroadcastNotification("from OpenHab - Doorbell Rang “+Timestamp+” x "+cnt)

end

gives up to 10 notifications

i’ve tried something like

cnt=cnt+1
if (cnt==1){
df = new SimpleDateFormat( “YYYY-MM-dd HH:mm:ss” )
Timestamp = df.format( new Date()

sendBroadcastNotification("from OpenHab - Doorbell Rang “+Timestamp+” x "+cnt)
}
if (cnt > 4)
{cnt=0}

but it just ends up doing nothing. is this the right approach or is there a better way of doing this? Many thanks…