Cancel timer doesn`t work

Rather than try to find the problem I’m going to suggest an alternative implementation.

If you are on 2.2 release change your Rule to:

rule "Fenster check"
when
    Item Door1 changed or
    Item Door2 changed or
    ...
then
    val lastUpdateDoor = triggeringItem
    ...

If on a recent 2.3 snapshot then you can use:

rule "Fenster check"
when
    Member of Door changed
then
    val lastUpdateDoor = triggeringItem
    ...

Then I’d trade this rather high degree of complexity in your Rules file for a few extra Items and Design Pattern: Expire Binding Based Timers coupled with Design Pattern: Associated Items.

Group:Switch DoorTimers

Contact Door1 (Door) ...
Switch Door1_Timer (DoorTimers) { expire="2m,command=OFF" }
...

Then your Rule greatly simplifies to:

rule "Fenster check"
when
    Item Door1 changed or
    Item Door2 changed or
    ...
then
    val timerItem = DoorTimers.members.findFirst[ door | door.name == triggeringItem.name +"_Timer" ]
    if(triggeringItem.state == CLOSED)  timerItem.postUpdate(OFF) // cancel timer
    else timerItem.sendCommand(ON) // set the timer
end

rule "Fenster timer"
when
    Item Door1_Timer received command OFF or
    Item Door2_Timer received command OFF or
    ...
then
    if(Temperature_outside.state <= 5) {
        logInfo("Rules", "Fenster " + triggeringItem.name.replace("_Timer", "") + " 10 Min. offen")
    }
    else if(Temperature_outside.state > 5 && Temperature_outside.state < 15) {
        logInfo("Rules", "Fenster " + triggeringItem.name.replace("_Timer", "") + " 30 Min. offen")
    }
end

No more maps, no more lambdas, no more sleeps, no more timers, half as many lines of code, and fewer levels of indentation. I think it is a fair trade for n more Items to implement the timers.

1 Like