By setting tRun
to null
your timer will get garbage collected and will not run. Also, between 04:00 and 10:00 it causes the if(tRun ===null ...
to be true hence running the commands again and again within that timeframe.
You probably want to avoid the Thread::sleep(5000)
and replace it by a timer because that blocks the rule thread for 5 seconds. There’s only a limited amount of rule threads that can be running at the same time (I think 5) so you want your rules to complete as soon as possible to not block any other rules from running.
Set tRun
to null
when the timer runs:
tRun = createTimer(now.plusHours(4), [|
logWarn("ruleName","Timer Off")
tRun = null
])
And have a look at the Time of Day design pattern.