Skip to content

Conversation

@florian-h05
Copy link
Contributor

No description provided.

@florian-h05 florian-h05 requested a review from a team as a code owner November 11, 2025 13:15
}
}

private String buildSource(@Nullable String source) {
Copy link
Contributor Author

@florian-h05 florian-h05 Nov 11, 2025

Choose a reason for hiding this comment

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

@ccutrer @kaikreuzer Please let me know what you think about my approach here of using the provided source or defaulting to the package name.
The motiviation for not delegating was that in many cases helper libraries will take care of providing a source, e.g. org.openhab.automation.javascript.script.test.js or org.openhab.automation.jsscripting$file:test.js, and in that case IMO it is confusing and unneccassary to have something like org.openhab.automation.javascript.script.test.js=>org.openhab.core.automation.module.script.

BTW, what of the above sources do you prefer?

Copy link
Member

Choose a reason for hiding this comment

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

yes, I think this is perfect. if a rule (or a helper library) sets a source, it should override the source completely, not just be the first delegation. my only ask would be do you think it would be possible to figure out the rule ID automatically here, and make that the actor? I know that might not work if it's in a timer or something, but it'd be nice for DSL rules that don't have a helper library. Which implies that my preference is for the source is <package>$<rule> for rules - org.openhab.automation.jsscripting$myrule (if possible to grab the full rule ID; if not then just file name is reasonable, though what would that be for non-file-based rules?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my only ask would be do you think it would be possible to figure out the rule ID automatically here, and make that the actor?

I see no way of doing that. The rule ID is injected into the script context somewhere else, and that context is "far away" here.

but it'd be nice for DSL rules that don't have a helper library.

If we assume that org.openhab.core.model.script.actions.BusEvent is ONLY used by rules DSL and all other environments use BusEvent from the ScriptAction script extension preset, we could at least hint to rules DSL; but I don't know how we would hint which rule.

Which implies that my preference is for the source is $ for rules - org.openhab.automation.jsscripting$myrule (if possible to grab the full rule ID; if not then just file name is reasonable, though what would that be for non-file-based rules?).

I also prefer $. The rule ID will be available and used for Script Actions and Script Conditions, for file based scripts the filename will be used. At least that will be my JS implementation.

@ccutrer
Copy link
Member

ccutrer commented Nov 11, 2025

LGTM as-is

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

lgtm as well, thanks!

@kaikreuzer kaikreuzer merged commit a1a92f2 into openhab:main Nov 13, 2025
4 checks passed
@kaikreuzer kaikreuzer added this to the 5.1 milestone Nov 13, 2025
@kaikreuzer kaikreuzer added the enhancement An enhancement or new feature of the Core label Nov 13, 2025
@florian-h05 florian-h05 deleted the busevent-source branch November 13, 2025 21:21
florian-h05 added a commit to florian-h05/openhab-core that referenced this pull request Nov 19, 2025
…EventImpl

org.openhab.core.automation.module.script...ScriptBusEventImpl was a copy of org.openhab.core.model.script...BusEvent,
which was removed in openhab#5122.
In openhab#5122, a org.openhab.core.automation.module.script...BusEventImpl was added, which is already used by the org.openhab.core.model.script bundle.

I think the ScriptBusEventImpl copy of the old BusEvent class was done to avoid a dependency org.openhab.core.automation.module.script => org.openhab.core.model.script.
As we now have a BusEventImpl in the automation bundle, we can use it for the DefaultScriptScopeProvider and get rid of ScriptBusEventImpl.

Signed-off-by: Florian Hotze <[email protected]>
kaikreuzer pushed a commit that referenced this pull request Nov 21, 2025
…EventImpl (#5136)

org.openhab.core.automation.module.script...ScriptBusEventImpl was a copy of org.openhab.core.model.script...BusEvent,
which was removed in #5122.
In #5122, a org.openhab.core.automation.module.script...BusEventImpl was added, which is already used by the org.openhab.core.model.script bundle.

I think the ScriptBusEventImpl copy of the old BusEvent class was done to avoid a dependency org.openhab.core.automation.module.script => org.openhab.core.model.script.
As we now have a BusEventImpl in the automation bundle, we can use it for the DefaultScriptScopeProvider and get rid of ScriptBusEventImpl.

Signed-off-by: Florian Hotze <[email protected]>
florian-h05 added a commit to florian-h05/openhab-js that referenced this pull request Nov 25, 2025
florian-h05 added a commit to florian-h05/openhab-js that referenced this pull request Nov 25, 2025
florian-h05 added a commit to florian-h05/openhab-js that referenced this pull request Nov 25, 2025
florian-h05 added a commit to openhab/openhab-js that referenced this pull request Nov 25, 2025
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.

3 participants