Rule with timer runs just once a time after reboot

Platform information:

*Hardware: RaspberryPi 3 Model B
*OS: OpenHab2
*Java Runtime Environment: Zulu Embedded 8.25.0.76-linux-aarch32hf, build 1.8.0_152-b76
*openHAB version:2.2

Hello,

the following rule runs just once a time after reboot.

What could be the issue? I compared it to several rule examples here in the forum, but couldn´t find a hint.

var Timer timerBadFenster = null

rule "BadFenster offen"

when

        Item BD_K_Fenster_State changed from CLOSED to OPEN


then
        if(timerBadFenster === null || timerBadFenster.hasTerminated) {
        logInfo("BadFenster","Bad Fenster wurde geoeffnet")

        timerBadFenster = createTimer(now.plusMinutes(30), [|
                logInfo("BadFenster","Nachricht senden")
            timerBadFenster = null
            sendTelegram("homesweethome", "Badfenster offen!")
        ])
    }
end

rule "Reset BadFenster Status"

when
        Item BD_K_Fenster_State changed to CLOSED

then

        if(timerBadFenster !== null) timerBadFenster.cancel()
        logInfo("BadFenster","Badfenster wurde geschlossen und Timer resetet")

end

Think of createTimer as a setTimeout in Javascript. It isn’t like a setInterval. If you want to repeat, call timer.reschedule at the end

Thanks for your reply, that´s not the problem. But this a good thing, so I could enhance my rule. :slight_smile:

The problem is, that after a reboot the rule works as expected, but the next times nothing happens. It runs just once until the next reboot or reload of the rule.

I guess there is an issue with the variable.