Stop double press on button

I have setup my home with a butload of Nexa dimmers and buttons and a PI with a Tellstick connected.

I don’t know if it is the buttons or Openhab2 but I think the last because I don’t remember the problem when I paired the buttons directly to the dimmers. If the problem was there before the lamps would start loop dimming with this problem.

All the buttons have an on and off switch that I turned in to a button each. Basically turning every switch in to 2 buttons.

But sometimes when I push a button Openhab2 runs the rule 2 times and first turn on and then off right after.

I tried using the ReentrantLock to block doublet presses with no luck. Do you guys have any idea how to prevent this from happening?
Iam thinking something that only allows one press every sec or two. But how?

The rule is quite simple

rule "Toilet Kontakt Trappe"
    Item Toilet_Kontakt received update OFF
    try {
      if (Kokken_Lys_Trappe.state == 0) {
      else {
    } finally{

If the rule is triggering twice it means Toilet_Kontakt is receive the update OFF twice.

Try using “received command OFF”, or changed to OFF instead. You might be receiving more than one update per button push. I don’t know enough about your setup to make a concrete suggestion as to what is an appropriate trigger.

The “received command” is for some reason not working on any of my buttons and “changed to” would not work since it is always OFF that controls that light.

I have a on/off switch that i have turned in to 2 buttons. So ON is controlling one light and OFF is controlling another.
I need the button to work even if it goes from OFF to OFF.

Do you guys need anything to make a qualified guess to fix the problem?

I don’t understand how your device is working but if you truly are receiving two updates per button press you will probably have to implement some sort of debounce logic in your rule. Basically, ignore any update that occurs within too short of a time of the last one.

If you set up persistence this can be done as easily as:

    if(Kokken_Lys_Trappe.lastUpdate.after(now.minusSeconds(1)) {
        // do rule logic
    // else ignore the event

Without persistence you can keep a timestamp of the last button push in a global var and compare to that:

var DateTime lastPush = null


    if(lastPush == null || lastPush.isAfter(now.minusSeconds(1)) {
        lastPush = now
        // do rule logic
    // else ignore

NOTE: you will have to look in your logs to see how quickly the two events are received and set the minusSeconds accordingly.

That’s perfect and easier than i thought.
I already have rrd4j so persistence is not a problem and it looks the most clean.


I get this error.

Error during the execution of rule 'Gang_Dorklokke': The name '<XMemberFeatureCallImplCustom>.after(<XMemberFeatureCallImplCustom>)' cannot be resolved to an item or type.

My persistence file look like this.

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
    // for rrd charts, we need a cron strategy
    everyMinute : "0 * * * * ?"

Items {
    * : strategy = everyChange, everyMinute, restoreOnStartup

It might be isAfter, not after.

Maybe, i have a second solution to this issue.
Some wall mount switches have a chatter so on one touch you get SOMETIMES two or more ON/OFF states.
You can test to connect a capacitor parallel to your switch. I test it with AC 230V and 0.33 uF (e.g. Merten 542895)

I must admit that i have given up on Openhab.
I have now written my own Python and and Bash scripts.