I have a rule that supposed to send me a mail when a door stays open too long(testing it with 2 min). It looks like this:
var Timer garageTimer
rule "Garagedeur telang open"
when
Item Garage_Door changed to OPEN or
Item Garage_Door changed to CLOSED
then
logInfo("Garagedeur", "Garagedeur "+Garage_Door.state)
if (garageTimer != null){
garageTimer.cancel
garageTimer=null
}
if (Garage_Door.state == OPEN){
garageTimer=createTimer(now.plusMinutes(2)) [ | sendMail("xxxxx@gmail.com","PASOP deur open","Deur is "+Garage_Door.state) ]
}
end
However, it seems to do nothing.
Now this rule has a bit of a history: months ago it ran perfectly, but then suddenly it would only run for 2 days after starting openhab and then no longer.
I then ggot the advise that it must be a damaged SD card on my raspberry 3 and that I should reinstall everything. Took a while, but I made a fresh install…everything OK except this rule not doing anything.
I did install the mail binding and configured my mail.cfg and I tested I can send mail from a rule, So what is the problem with this one, it used to work, have I forgotten something?
Thanx, Seemed to solve it. I am baffled as it was just the same old rule that had worked before.
In the mean time I had found a method that works with expire, though it acts a bit different (repeats messages).Design Pattern: Recursive Timers
@Kees_van_Gelder I changed the items to work with my setup using this rule.
var Timer garageTimer
rule "Garagedeur telang open"
when
Item CouchLight changed to ON or
Item CouchLight changed to OFF
then
logInfo("Garagedeur", "Garagedeur "+CouchLight.state)
if (garageTimer !== null){
garageTimer.cancel
garageTimer=null
}
if (CouchLight.state == ON){
garageTimer=createTimer(now.plusMinutes(2)) [ |
OfficeLight.sendCommand(ON) ]
}
end