Skip to content

DSL Scripts and Rules: allow usage of org.openhab.core.automation.RuleManager#5484

Merged
mherwege merged 1 commit into
openhab:mainfrom
dilyanpalauzov:rulemanager_fromdsl
May 4, 2026
Merged

DSL Scripts and Rules: allow usage of org.openhab.core.automation.RuleManager#5484
mherwege merged 1 commit into
openhab:mainfrom
dilyanpalauzov:rulemanager_fromdsl

Conversation

@dilyanpalauzov

Copy link
Copy Markdown
Contributor

The changeset allows running from DSL Rules and DSL Sctipts a rule:

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")

@lolodomo

lolodomo commented May 2, 2026

Copy link
Copy Markdown
Contributor

Why not ?

@lolodomo

lolodomo commented May 3, 2026

Copy link
Copy Markdown
Contributor

@Nadahar: is it something needed/expected for what is discussed about future for DSL rule/script?

@Nadahar

Nadahar commented May 3, 2026

Copy link
Copy Markdown
Contributor

This is done/needed in #5481 for the rule bundle, it's hard to see how it can hurt to also make it available to the script package - although I'm not sure exactly when/if that is needed.

I assume that @dilyanpalauzov knows why it's also needed for the script package.

@dilyanpalauzov

Copy link
Copy Markdown
Contributor Author

It is needed in the scripts bundle, so that the above example can be executed in DSL Scripts, outside of DSL Rules. (You can try youself the snippet before and after changing core.module.script/bnd.bnd)

@lolodomo

lolodomo commented May 4, 2026

Copy link
Copy Markdown
Contributor

This is done/needed in #5481 for the rule bundle

Understood now that I read #5481. #5481 is more useful than this one and make this one useless.

With #5481, I understand that the code example in the current PR can simply be replaced by:

Rules.runRule(r2)

which is definitvely eaiser.

@Nadahar

Nadahar commented May 4, 2026

Copy link
Copy Markdown
Contributor

With #5481, I understand that the code example in the current PR can simply be replaced by:

Rules.runRule(r2)

which is definitvely eaiser.

Yes, it's easier, and #5481 also does many other things, like allowing to easily edit Item metadata for example. But, that doesn't make this "useless". This makes it possible to resolve classes in the automation bundle both from DSL rules and DSL scripts. #5481 "help you" make it convenient to do some of these things, but resolving the classes is still necessary.

What I don't know is why you'd want to do it from DSL scripts that isn't part of a rule, but that doesn't mean that it's wrong to make it possible.

@rkoshak

rkoshak commented May 4, 2026

Copy link
Copy Markdown

What I don't know is why you'd want to do it from DSL scripts that isn't part of a rule, but that doesn't mean that it's wrong to make it possible.

E.g., access Item metadata in a DSL transformation to decide how to transform something.

@dilyanpalauzov

Copy link
Copy Markdown
Contributor Author

What I don't know is why you'd want to do it from DSL scripts that isn't part of a rule

Writing DSL Script, which is part (action) of a UI rule, and thus not part of a DSL Rule, also needs the change in code.model.script/bnd.bnd. Compare to the problem description of #4784.

@Nadahar Nadahar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mherwege mherwege left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mherwege

mherwege commented May 4, 2026

Copy link
Copy Markdown
Contributor

FTR: small patch exception

@mherwege mherwege added this to the 5.2 milestone May 4, 2026
@mherwege mherwege added the enhancement An enhancement or new feature of the Core label May 4, 2026
@mherwege mherwege merged commit b76a02c into openhab:main May 4, 2026
5 of 6 checks passed
@dilyanpalauzov dilyanpalauzov deleted the rulemanager_fromdsl branch May 4, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature of the Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants