Are many "createTimer" bad?

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:

  • When Kodi stops playing start a 20 minute timer. If it is still stopped, turn the lights out
  • Switch multiple remote sockets at the same time. Switch the first, wait 2 seconds and switch the next, etc…
  • When openhab server doesn’t recieve pings from a specific server wait 5 minutes before sending a message

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"
    Item LightsProxy received command
    if(LightsProxy.state == ON){
    else {