[SOLVED]Maybe I need a delay in my rule?

Oh no, Thread::sleep() is the only way to wait in a rule. A timer would be more complex:

var Timer tTimer = null // define global vars at the top of the file

rule "rule with timed sleep"
when
    Time cron "0 0 23 * * ?"
then
    tTimer?.cancel  // kill any existing timer
    logInfo("SonoffRFBridge", "Sparkley Darkies turned off")
    SonoffRFBridge_SparkleyDarkleyJar01.sendCommand(OFF)
    tTimer = createTimer(now.plusSeconds(1), [|
        SonoffRFBridge_SparkleyDarkleyJar2.sendCommand(OFF)
    ])    
end

The difference is, Thread::sleep() will pause the Thread (and the Thread keeps occupied) where the Timer code will be scheduled. the Rule will end immediately, and the timer is executed at the scheduled time.

See this posting:

2 Likes