Hi,
I have about 40 createTimer in my rules file. Is this bad, because they waste cpu time and memory even after the timer expired? And will normal variables unset after the rule finished?
Is Thread::sleep(10000) better?
Hi,
I have about 40 createTimer in my rules file. Is this bad, because they waste cpu time and memory even after the timer expired? And will normal variables unset after the rule finished?
Is Thread::sleep(10000) better?
Thread:sleep and Timers are used for two very different purposes. They are not interchangeable.
40 Timers does seem like a lot and it makes me wonder if there is a more efficient way to do it but not knowing why you have that many I can’t make a concrete comment.
Several reasons:
The second could be implemented better, but I don’t know how. I allways need timers in this situation.
Thread::sleep is probably a more appropriate way to implement the middle one. The other two are best implemented with Timers.
I would approach the second by putting all the lights that need to be controlled like that in a Group, create a proxy Switch to control them as a Group, and create a rule which triggers on the proxy Switch:
rule "Serial lights"
when
Item LightsProxy received command
then
if(LightsProxy.state == ON){
gLightsGroup.members.forEach[light|
light.sendCommand(ON)
Thread::sleep(2000)
]
}
else {
...
end