Hi,
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.
Thanks!
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);
logger.info(status1);
if (status1 < 5) {
logger.info('power less than 5 W - check again in 60 seconds');
java.lang.Thread.sleep(60000);
var test = itemRegistry.getItem('Power18LUMI_Power').getState().toString();
var status2 = test.substring(0,test.length-2);
logger.info(status2);
if (status2 < 5) {
logger.info('power less than 5 W for more than 60 seconds');
}
}