From 8029b37c2638b40426120f41f9a8de6e3f10a053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B8=D0=BB=D1=8F=D0=BD=20=D0=9F=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=D1=83=D0=B7=D0=BE=D0=B2?= Date: Sat, 9 May 2026 12:18:38 +0300 Subject: [PATCH] JSR223: Update Groovy example --- configuration/jsr223.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/configuration/jsr223.md b/configuration/jsr223.md index 8bd8006b07..859a50ac11 100644 --- a/configuration/jsr223.md +++ b/configuration/jsr223.md @@ -146,22 +146,25 @@ import org.openhab.core.automation.module.script.rulesupport.shared.simple.* import org.openhab.core.config.core.Configuration scriptExtension.importPreset("RuleSupport") -scriptExtension.importPreset("RuleSimple") -def sRule = new SimpleRule() { +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 inputs) { - println("Hello World from Groovy") + org.slf4j.LoggerFactory.getLogger("A").error("Hello World from Groovy") } -} -sRule.setTriggers([ - TriggerBuilder.create() - .withId("aTimerTrigger") - .withTypeUID("timer.GenericCronTrigger") - .withConfiguration(new Configuration([cronExpression: "0 * * * * ?"])) - .build() - ]) - -automationManager.addRule(sRule) +}) ``` :::