As a side note, for Groovy⇔openHAB-Automation users JSR223: Update Groovy example by dilyanpalauzov · Pull Request #2720 · openhab/openhab-docs · GitHub suggests concise way to utilize SimpleRule:
import org.openhab.core.automation.*
import org.openhab.core.automation.module.script.rulesupport.shared.simple.*
import org.openhab.core.config.core.Configuration
scriptExtension.importPreset("RuleSupport")
automationManager.addRule(new SimpleRule() {
{
name = "Main"
description = "Primary Logic"
uid = "1-2-3"
tags = ["T"]
triggers = [
TriggerBuilder.create()
.withId("aTimerTrigger")
.withTypeUID("timer.GenericCronTrigger")
.withConfiguration(new Configuration([cronExpression: "0 * * * * ?"]))
.build()
]
}
Object execute(Action module, Map<String, ?> inputs) {
org.slf4j.LoggerFactory.getLogger("A").error("Hello World from Groovy")
}
})