From 1cca5a1ccf8135fa8339505bc2940b38904b13b3 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: Mon, 13 Apr 2026 10:30:31 +0300 Subject: [PATCH] Groovy: example run a rule --- tutorials/getting_started/rules_scenes.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tutorials/getting_started/rules_scenes.md b/tutorials/getting_started/rules_scenes.md index deb2fa12c1..ef45750a5a 100644 --- a/tutorials/getting_started/rules_scenes.md +++ b/tutorials/getting_started/rules_scenes.md @@ -114,7 +114,19 @@ Use the following block and add the _scene id_ to the block to call the scene Save it and that's it. ::: -::: tab JS +::: tab Groovy + +```groovy +var ruleManagerBundleContext = org.osgi.framework.FrameworkUtil.getBundle(org.openhab.core.automation.RuleManager).bundleContext +var ruleManagerServiceReference = ruleManagerBundleContext.getServiceReference(org.openhab.core.automation.RuleManager) +var ruleManager = ruleManagerBundleContext.getService(ruleManagerServiceReference) +ruleManager.runNow("scene_office_dimmed_light") +ruleManagerBundleContext.ungetService(ruleManagerServiceReference) +``` + +::: + +::: tab JS Scripting ```javascript rules.runRule('scene_office_dimmed_light', {}); @@ -127,7 +139,7 @@ Save it and that's it. rules[“id”] gives you the rule object for the given id, which supports the [trigger method](https://openhab.github.io/openhab-jruby/main/OpenHAB/Core/Rules/Rule.html#trigger-instance_method) (aliased as run). ```ruby - rules["scene_id"].run + rules["scene_office_dimmed_light"].run ``` ::::