How to create a rule, which only executes some code, if a value does not change for a certain period of time


I have a question about the Sample Rule in Github:

import org.openhab.model.script.actions.Timer
var Timer timer

rule "do something if item state is 0 for more than 10 seconds"
Item MyItem changed
if(MyItem.state==0) {
timer = createTimer(now.plusSeconds(10)) [|
// do something!
} else {
if(timer!=null) {
timer = null

If I set the timer to 3600 seconds (1 hour), is OpenHAB able to run other rules or does the system just stay in this rule until the time is over?
Because I need to check if a value does not change over 1-2 hours and of course should perform other rules in this time.

Thank you in advance!


But one questions, how would I edit this rule to check if the value does not change for 2 hours.
This rule only works when the item state is 0 - but the state changes every 30 minutes to a different state. Where I have to put the variable?

createTimer(now.plusMinutes(120)) or

1 Like