createTimer is used to schedule a bit of code to run at sometime in the future.
You can’t prevent a Rule from running when an event occurs. So you need to use if statements to decide what code the Rule runs when it is triggered.
There are lots of ways to do this but createTimer isn’t one of them. Using a timestamp is probable the safest.
var lastRun = now.minusMinutes(601) // set to the past
rule "phone1 online"
when
Item phone1_Online changed to ON
then
if(now.minusMinutes(600).isAfter(lastRun)) return; // if it has been less than 600 minutes since we last ran exit
MyEchoDot_Speak.sendCommand('Good day master. I am ready to do your bidding')
lastRun = now
end
You could also have used another switch with the expire binding
Switch timerSwitch { expire="10h, OFF" }
The rule
rule "phone1 online"
when
Item phone1_Online changed to ON
then
if (timerSwitch.state == ON) return; // The timer is already running so we do nothing
MyEchoDot_Speak.sendCommand('Good day master. I am ready to do your bidding')
timerSwitch.sendCommand(ON) // start the timer
end
Unless you after using the var in all off your rules either there is a syntax error so the .rules file never loaded or something else is going wrong. There is nothing about that rule that can cause that to happen.