Skip to content

Conversation

dilyanpalauzov
Copy link
Contributor

I add example only for Groovy, as I do know how to use it in the other automation add-ons. Besides, the other rule engines provide other ways for the same functionality: script_unloaded in JRuby, and for others I do not know if the functionality is from openhab-core, or from the add-on.

Copy link

netlify bot commented Oct 2, 2025

Thanks for your pull request to the openHAB documentation! The result can be previewed at the URL below (this comment and the preview will be updated if you add more commits).

Built without sensitive environment variables

Name Link
🔨 Latest commit 1c96144
🔍 Latest deploy log https://app.netlify.com/projects/openhab-docs-preview/deploys/68de632918037a0007e68fb8
😎 Deploy Preview https://deploy-preview-2567--openhab-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dilyanpalauzov dilyanpalauzov marked this pull request as ready for review October 2, 2025 11:39
Copy link

netlify bot commented Oct 2, 2025

Thanks for your pull request to the openHAB documentation! The result can be previewed at the URL below (this comment and the preview will be updated if you add more commits).

Built without sensitive environment variables

Name Link
🔨 Latest commit 746786d
🔍 Latest deploy log https://app.netlify.com/projects/openhab-docs-preview/deploys/68de63e6806756000875d2f8
😎 Deploy Preview https://deploy-preview-2567--openhab-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Oct 2, 2025

Thanks for your pull request to the openHAB documentation! The result can be previewed at the URL below (this comment and the preview will be updated if you add more commits).

Built without sensitive environment variables

Name Link
🔨 Latest commit d68ff70
🔍 Latest deploy log https://app.netlify.com/projects/openhab-docs-preview/deploys/68ef8f739edd1c00088a29ab
😎 Deploy Preview https://deploy-preview-2567--openhab-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dilyanpalauzov dilyanpalauzov force-pushed the lifecycle_preset branch 4 times, most recently from a09886c to b1f7fa7 Compare October 3, 2025 11:34
@dilyanpalauzov
Copy link
Contributor Author

Now includes Nashorn example.

@dilyanpalauzov
Copy link
Contributor Author

The current proposed change is correct, but only part of the truth. My understanding is that if a class implements ScriptExtensionProvider and returns in getDefaultPresets() non-empty set, then it is loaded by default by org.openhab.core.automation.module.script.internal.ScriptExtensionManager:

    public List<String> getDefaultPresets() {
        List<String> defaultPresets = new ArrayList<>();
        for (ScriptExtensionProvider provider : scriptExtensionProviders) {
            defaultPresets.addAll(provider.getDefaultPresets());
        }
        return defaultPresets;
    }

That is, the MediaScriptScopeProvider, LifecycleScriptExtensionProvider and DefaultScriptScopeProvider script extensions, or in other words the default, media and lifecycle presets, do not require importPresent.

@dilyanpalauzov dilyanpalauzov force-pushed the lifecycle_preset branch 2 times, most recently from 5a27a98 to a13b13b Compare October 4, 2025 11:48
@dilyanpalauzov
Copy link
Contributor Author

Besides, one of the presets, which is loaded without importPreset is called default, not “Defaut”: In https://github.com/openhab/openhab-core/blob/main/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/DefaultScriptScopeProvider.java: private static final String PRESET_DEFAULT = "default";

@dilyanpalauzov dilyanpalauzov force-pushed the lifecycle_preset branch 2 times, most recently from 7d1cde9 to 1923155 Compare October 4, 2025 13:08
@dilyanpalauzov dilyanpalauzov changed the title JSR223 mention lifecycle preset JSR223 mention lifecycle and media presets Oct 4, 2025
@dilyanpalauzov
Copy link
Contributor Author

I added also the media preset - variables org.openhab.core.audio.AudioManager audio and org.openhab.core.voice.VoiceManager video.

Copy link
Contributor

@stefan-hoehn stefan-hoehn left a comment

Choose a reason for hiding this comment

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

@florian-h05 please check the content.


#### `lifecycle` Preset (`importPreset` not required)

It provides a mechanism to execute code, when the input file is deleted. Modifying a file deletes it and creates it again.
Copy link
Contributor

Choose a reason for hiding this comment

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

2nd sentence has be in the next line. (make sure the first sentence doesn't have a trailing space then.

@dilyanpalauzov dilyanpalauzov changed the title JSR223 mention lifecycle and media presets JSR223 mention lifecycle and media presets, scriptLoaded and scriptUnloaded functions Oct 11, 2025
@dilyanpalauzov
Copy link
Contributor Author

I have described also the scriptLoaded(String) and scriptUnloaded() functions, and included examples in Groovy, JavaScript and Python.

@dilyanpalauzov dilyanpalauzov force-pushed the lifecycle_preset branch 6 times, most recently from bf4b509 to a9b1964 Compare October 11, 2025 19:50
@dilyanpalauzov dilyanpalauzov force-pushed the lifecycle_preset branch 4 times, most recently from f27cdec to a5603b2 Compare October 13, 2025 11:41
@dilyanpalauzov dilyanpalauzov changed the title JSR223 mention lifecycle and media presets, scriptLoaded and scriptUnloaded functions JSR223 mention lifecycle, media and provider presets, scriptLoaded and scriptUnloaded functions Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants