Multiple Events may occur in a short period of time. How to ignore?

Hello,

I setup a door bell sensor. This works fine and now I want to setup some rules on it.

Rules are also working fine so far but I wanted to be able to check whether the button was pushed more than once. For example if I would setup a mobile phone push notification every time the button is pressed I would receive 3 or 4 messages for the same person standing in front of my door.

Is it possible to ignore the second till x event for a specified period of time (for example one minute)? The rule event should happen only once.

This is my current rule:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*

rule "door bell"
when
	Item hm_klingel received update ON
then
	logInfo("Door Bell","Somebody pushed the bell button.")
end

Thanks in advance!

var Timer lockklingel = null

rule "door bell"
when
	Item hm_klingel received update ON
then
       if(lockklingel == null) {        // if not blocked
            lockklingel = createTimer(now.plusMinutes(2), [ |     // create block
                  lockklingel = null                                             // release block later
            ]
        logInfo("Door Bell","Somebody pushed the bell button.")   // do whatever immediately
end

Many thanks. Sometimes things could be so easy :sunglasses:

You only missed one bracket. Just let me post the correct code for all users reading this thread later:

var Timer lockklingel = null

rule "door bell"
when
	Item hm_klingel received update ON
then
       if(lockklingel == null) {        // if not blocked
            lockklingel = createTimer(now.plusMinutes(2), [ |     // create block
                  lockklingel = null                                             // release block later
            ])
        logInfo("Door Bell","Somebody pushed the bell button.")   // do whatever immediately
end