Sleep timer

Hi there!

I have many rules in Openhab 2 that switch on a light with a delay and then switch off the same light again after 10 minutes.

For this I have the command “Thread :: sleep (3000)” in my rules

How can you use such a rule in Openhab 3?


The same as you do now. Only in OH 2 those rules were really dangerous and now they are not so bad.

Though it would be much better to use a Timer for something like this or even the Expire config on the Item to not even need a rule.

Note that Thread::sleep blocks the rule. The line that follows the sleep won’t run until later. When you create a Timer, the code will run at the given time but the rule will continue to execute in the mean time.

Search the forum for createTimer or look in the Actions page in the docs for lots and lots of examples.