var Timer mcloset
rule "Master Closet Lights Left On"
when
Item MasterCloset changed to ON or
Item MasterCloset changed to OFF
then
if(mcloset != null) {
mcloset.cancel
mcloset = null
}
if(MasterCloset.state == ON){
mcloset = createTimer(now.plusMinutes(10)) [|
MasterCloset.sendCommand(OFF)
]
}
end
I tried your rule and it did not work initially, in fact I could find no items in the log file either.
The rule was on a page with three other iterations of the same rule for other lights.
Just to be sure I created a new rules document with only the one rule and sure enough it worked! I even went back and tried my original rule on it’s own individual page and sure enough it worked as well!
I have placed multiple rules on the same page many times previously…is there something special I need to do with timers? Each rule has an end statement?
Am I missing something simple?
Thanks,
Squid
Here’s the rules file with multiple entries:
var Timer zclosettimer
rule "Zane's Closet Lights Left On"
when
Item ZaneCloset changed to ON or
Item ZaneCloset changed to OFF
then
if(zclosettimer != null) {
zclosettimer.cancel
zclosettimer = null
}
if(ZaneCloset.state == ON){
zclosettimer = createTimer(now.plusMinutes(5)) [|
ZaneCloset.sendCommand(OFF)
]
}
end
var Timer zsconcetimer
rule "Zane's Sconces Left On"
when
Item ZaneSconce changed to ON or
Item ZaneSconce changed to OFF
then
if(zsconcetimer != null) {
zsconcetimer.cancel
zsconcetimer = null
}
if(ZaneSconce.state == ON){
zsconcetimer = createTimer(now.plusMinutes(60)) [|
ZaneSconce.sendCommand(OFF)
]
}
end
var Timer mcloset
rule "Master Closet Lights Left On"
when
Item MasterCloset changed to ON or
Item MasterCloset changed to OFF
then
if(mcloset != null) {
mcloset.cancel
mcloset = null
}
if(MasterCloset.state == ON){
mcloset = createTimer(now.plusMinutes(10)) [|
MasterCloset.sendCommand(OFF)
]
}
end
Putting all the var at the top is one of those things that shouldn’t matter, but it seems it does.
When you get it working, for this simple application you might consider instead installing the expire binding. It’s not always appropriate, but for lighting timeouts is ideal.