Thanks @rlkoshak I’ll look into this and try and learn from you example how ![]()
Oh well, my “fix” didn’t work.
But I think I found a solution. Been doing some debugging using ‘infoLog’. It is the createTimer that seems to not work everytime but after changing some code, it seems to have become stable.
Replaced this
if(tGarageDoor1 == null || tGarageDoor1.hasTerminated)
With
if(tGarageDoor2 != null) tGarageDoor2.cancel() { //Terminate timer if one is already started
So now the complete rule lookes like this
// This rule sends a telegram notification if garage door has been open for 30 min.
rule "Send telegram Notification | Garage door 2 open for 30 min."
when
Item Garage_Port_2_State_Closed changed to CLOSED
then
if(tGarageDoor2 != null) tGarageDoor2.cancel() { //Terminate timer if one is already started
tGarageDoor2 = createTimer(now.plusMinutes(1), [|
tGarageDoor2 = null
sendTelegram((TelegramBots), (Message4))
logInfo("TimerEnded", "Send telegram Notification | Garage door 2 open for 30 min.")
])
logInfo("TimerStarted", "Will send telegram Notification if garage door 2 is not closed within 30 min.")
}
end
rule "Cancel telegram Notification | Garage door 2 open for 30 min."
when
Item Garage_Port_2_State_Closed changed to OPEN
then
if(tGarageDoor2 != null) tGarageDoor2.cancel() //Terminate timer if door is closed before the timer ends
end
I’ll keep an eye on things ![]()