Prevent rule from triggering twice

Hi I’m having problems to prevent my rules for handling my doorbells everytime someone pushes the button my rules excecutes wich I guess i right. But I would prefer to be able to set like 30 or 60 seconds delay since last excecuted so I get i decent chanse to open the door. I’ve tried this where z19 is the fibaro universal sensor ans GDO_bells is my master switch to silenc doorbells. Hope you guys have some ideas.

if (gDO_bells.state==ON && z19.state.lastUpdate.after(now.minusSeconds(1)))

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.

1 Like

… or configure parameter 1 (for IN1) or 2 (for IN2) to a “alarm cancellation delay”.

I just implemented Ricks solution works as a sharm then it’s easier to setup with openhab. I supose alarm cancellation delay maybe delays even the first alarm?

Nope. It just delays the possibility to activate the input again during the time frame of the value you put in there.

The I assuemd wrong then. But regarding confuguration of parameters via Habmin, could I see in the log or something whens it’s all done? I only see wait for a long period of time in the Habmin web page.

If you have a zwave battery device and you change parameters, you will see a “pending” mark until that change is transferred to the device.
You may speed that up by waking the device up, sometimes you will have to do that several times. Then the pending mark will disappear and the config has been changed.
Note that waking up a device does not mean you just trigger the input. You will have to wake it up by pressing a button.

In case of the Fibaro universal sensor: that device is normally powered by low voltage pwr supply, not batteries (they won’t last very long), so the settings should be transferred immediately.

I noticed that with my nodon wallswitch that i need to push a button on it in order to make configuration programmed. I now have two good ways for handling this both with rules and programming parameter. Thanks alot fpor all your help, maybe I could go off topic a littlebit and see if you know how Z wave communication is done, I’m thoinking abou when I send ON to a device do the device sendas some confirmationa back? Beacause sometimes it looks like a device is on but it hasn’t turnd on.

Sure, that is one of the most important features why people are choosing zwave:

Two-way wireless communication - all messages acknowledged, if one gets lost it is automatically repeated

That wath’s I supposed to, but are the Icon in a switch in openhab turned red if it doesn’t get ack?

Green means switch is ON, red means switch is OFF.
If that does not work, most common mistake is that you did not set the association group for controller updates to the controller.
Sometimes that association group is called “Group 1” or “Lifeline” or “Controller Group” or whatever (take a look at your manual). In case of the Fibaro universal sensor it is group 3 “Controller Updates”.
If it still does not work you need to find out if you have any syntax errors in your sitemap definition, that could also cause problems. Best is to check the syntax with the ESHD.

Thanks again for all input, know I have a stupid question about the rule Rick bosted, i use it now but the first time my dorrbell rule will trigger froms startup openha2 it wont trig the rule I assuem that might be since OH really don’t know when lastring where? could I make somekind of startup scriot in my rulesfiel or can I set a persitance service to variable lastring?

Hi
There is a missing parentheses here (“if(..”)

if(lastRing.isBefore(now.minusSeconds(30))){

}