Skip to content

Commit 97dbe10

Browse files
DSL Rules: example run a rule
1 parent ebbc4a7 commit 97dbe10

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

configuration/rules-dsl.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,18 @@ then
955955
end
956956
```
957957

958+
### Run A Rule
959+
960+
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)):
961+
962+
```java
963+
val ruleManagerBundleContext = org.osgi.framework.FrameworkUtil.getBundle(org.openhab.core.automation.RuleManager).bundleContext
964+
val ruleManagerServiceReference = ruleManagerBundleContext.getServiceReference(org.openhab.core.automation.RuleManager)
965+
val ruleManager = ruleManagerBundleContext.getService(ruleManagerServiceReference)
966+
ruleManager.runNow("r2")
967+
ruleManagerBundleContext.ungetService(ruleManagerServiceReference)
968+
```
969+
958970
## Further Examples
959971

960972
Many more examples can be found in the [Tutorials & Examples](https://community.openhab.org/c/tutorials-examples) category of the community forum.

0 commit comments

Comments
 (0)