OpenHAB3: Check condition again after x minutes


I want to find out if my washing machine is ready. I am using a power plug to check the current power and check it again after 60 seconds if the power is less than 5 W.

Therefore I use this script and it works well. But how can I make a rule that depends on this script? My idea is to change the color of one of my hue lights.


var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
var test = itemRegistry.getItem('Power18LUMI_Power').getState().toString();
var status1 = test.substring(0,test.length-2);;

if (status1 < 5) {'power less than 5 W - check again in 60 seconds');

  var test = itemRegistry.getItem('Power18LUMI_Power').getState().toString();
  var status2 = test.substring(0,test.length-2);;

  if (status2 < 5) {'power less than 5 W for more than 60 seconds');


You use sleep() and your testing is not reliable. Rather than start fiddling in there, better search the forum for washing machine there’s a full thread that’s including tested code. I think that even became part of the OH3 tutorial so check that out, too.