From 55f939f30b8646dd22486d8484a9ee981e0ca2bf 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:28:03 +0300 Subject: [PATCH] DSL Rules: example to disable a thing --- configuration/rules-dsl.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configuration/rules-dsl.md b/configuration/rules-dsl.md index f749bfff44..316b133061 100644 --- a/configuration/rules-dsl.md +++ b/configuration/rules-dsl.md @@ -955,6 +955,18 @@ then end ``` +### Disable Thing + +Disable things with UID `enocean:bridge:e` and `mqtt:topic:m` using [`ThingManager.setEnabled()`](https://openhab.org/javadoc/latest/org/openhab/core/thing/thingmanager#setEnabled(org.openhab.core.thing.ThingUID,boolean)): + +```java +val thingManagerBundleContext = org.osgi.framework.FrameworkUtil.getBundle(org.openhab.core.thing.ThingManager).bundleContext +val thingManagerServiceReference = thingManagerBundleContext.getServiceReference(org.openhab.core.thing.ThingManager) +val thingManager = thingManagerBundleContext.getService(thingManagerServiceReference) +#["enocean:bridge:e", "mqtt:topic:m"].forEach[ thingManager.setEnabled(new org.openhab.core.thing.ThingUID(it), false) ] +thingManagerBundleContext.ungetService(thingManagerServiceReference) +``` + ## Further Examples Many more examples can be found in the [Tutorials & Examples](https://community.openhab.org/c/tutorials-examples) category of the community forum.