This is also called “debounce” and if you search the forum for that you will find lots of other posts.
There are a ton of ways to implement it besides ReentrantLocks. For your use case I would probably recommend just using a timestamp.
var lastRing = now
rule "Doorbell"
when
Item Doorbell received command
then
if(lastRing.isBefore(now.minusSeconds(30)) {
// make the doorbell sound/alert
lastRing = now
}
end
This way doesn’t depend on finiky locks nor does it require persistence which lastUpdate would require.