Detect dubbelt press

Hi.

Why is this not working?
I want it to return true if i push the button 2 times within within 30 sec.

My items files have this
String KnapA “KnapA [%s]” (Kontakter) {channel=“zwave:device:a3ceef84:node2:scene_number”}

And my rules file have this.
if (KnapA.lastUpdate.isAfter(now.minusSeconds(30)) {
logInfo(“Test”, “Nubnub”)
}

I have persist active

As the rule would trigger through KnapA, I think, KnapA.lastUpdate will be always ~ now() You will have to use another counter:

var Timer tKnapA = null

rule "detect double press"
when
    Item KnapA received update
then
    if (tKnapA != null) {
        logInfo("Test","Nubnub")
        tKnapA.cancel
        tKnapA = null
    }
    else
        tKnapA = createTimer(now.plusSeconds(30),[|
                    logInfo("Test","Nub")
        ])
end

Hi. Thanks.

It looks like it fails at
Timer tKnapA = null

Configuration model ‘huset.rules’ is either empty or cannot be parsed correctly!

Is there any place where i can find all this advanced commands like now.plusSeconds(30)?

Argh… sorry, should be

var Timer tKnapA = null

(will correct this in my prior posting)

Thanks that works.