diff --git a/configuration/rules-dsl.md b/configuration/rules-dsl.md index f749bfff44..9fffdb7de5 100644 --- a/configuration/rules-dsl.md +++ b/configuration/rules-dsl.md @@ -955,6 +955,18 @@ then end ``` +### Run A Rule + +A rule with UID `r2` can be executed with [RuleManager.runNow()](https://openhab.org/javadoc/latest/org/openhab/core/automation/rulemanager#runNow(java.lang.String)): + +```java +val ruleManagerBundleContext = org.osgi.framework.FrameworkUtil.getBundle(org.openhab.core.automation.RuleManager).bundleContext +val ruleManagerServiceReference = ruleManagerBundleContext.getServiceReference(org.openhab.core.automation.RuleManager) +val ruleManager = ruleManagerBundleContext.getService(ruleManagerServiceReference) +ruleManager.runNow("r2") +ruleManagerBundleContext.ungetService(ruleManagerServiceReference) +``` + ## Further Examples Many more examples can be found in the [Tutorials & Examples](https://community.openhab.org/c/tutorials-examples) category of the community forum.