I’ve released Beta 2 of Java Scripting for openHAB to GitHub - weberjn/org.openhab.automation.javascripting .
It works similar to Groovy Scripting, only with Java as language.
Beta 2 supports Rules definitions with Java Annotations.
I’d be grateful if people test and play with Java Scripting.
There several samples in the README.
The previous discussion is here.
..
public class CronRule extends Script {
private Logger logger = LoggerFactory.getLogger("org.openhab.automation.javascripting.cronrule");
private int counter = 1;
@Rule(name = "CronRule")
@CronTrigger(id = "CronTrigger", cronExpression = "0 * * * * ?")
public SimpleRule cronrule = new SimpleRule() {
@Override
public Object execute(Action module, Map<String, ?> inputs) {
logger.info("Java cronrule execute {}", counter++);
return "";
}
};
@Override
protected void onLoad() {
logger.info("Java onLoad()");
};
}