[SOLVED] Help with timer

Ah, sorry, as there are two if statements in a row, we need another pair of curly brackets.

var Timer tDoorAlarm = null

rule "door alarm"
when
    Item MyDoorContact changed
then
    if(MyDoorContact.state == OPEN) {   // <-- additional curly bracket
        if(tDoorAlarm === null)
            tDoorAlarm = createTimer(now.plusMinutes(2), [|
                // sendMail("mail@address", "Fridge Alarm!", "Fridge door is open since two minutes..." )
            ])
    }                    // <-- additional curly bracket
    else {
        tDoorAlarm?.cancel
        tDoorAlarm = null
    }
end
1 Like