You’ve tested multiple times for gargelighttimer==null, but this is probably false even when the timer is not doing anything.
You don’t actually need to reschedule, just garagelighttimer.cancel and garagelighttimer=null, then set it again:
Here’s a useful template for setting an action for a timer, just replace MOTION, TIMER, LIGHT and BRIGHTNESS (When you get it) to suit your needs.
var org.openhab.model.script.actions.Timer TIMER
rule "Motion Turns On Light"
when
Item MOTION changed from OFF to ON
then
if (BRIGHTNESS.state < 25) {
LIGHT.sendCommand(ON)
}
end
rule "Motion Time Out"
when
Item Motion changed
then
if(TIMER!=null) {
TIMER.cancel
TIMER = null
}
if(MOTION.state==OFF){
TIMER = createTimer(now.plusMinutes(1)) [|
LIGHT.sendCommand(OFF)
]
}
end
(If anyone else is reading this post, some motion sensors are contact items, so don’t forget to change OFF to CLOSED and ON to OPEN.)