You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing rules in JSR 223, one ultimately has to access automationManager to do something useful. The presets - Default, RuleSimple, RuleSupport, RuleFactories, ScriptAction and cache - provide some implicit imports and objects (variables). The latter objects enable connecting the JSR223 code with the OH internals and installing some meaningful automation.
As the only way described at https://www.openhab.org/docs/configuration/jsr223.html to install a rule is to use automationManager and thus to import the RuleSupport preset, this preset has always to be included explicitly by the caller. The other items from the preset are not strictly necessary, as they can be obtained by imports. (And the imports are required to move as much code in Groovy as possible under the TypeChecked and CompileStatic annotations).
The text was updated successfully, but these errors were encountered:
You can obtain automationManager through scriptExtension.get("automationManager"). scriptExtension is injected by default, without having to import any presets.
Yes, this is indeed the case. But this is not documented at https://www.openhab.org/docs/configuration/jsr223.html, so scriptExtension.importPreset("RuleSupport") is always called in order to get access to automationManager.
When writing rules in JSR 223, one ultimately has to access
automationManager
to do something useful. The presets - Default, RuleSimple, RuleSupport, RuleFactories, ScriptAction and cache - provide some implicitimport
s and objects (variables). The latter objects enable connecting the JSR223 code with the OH internals and installing some meaningful automation.As the only way described at https://www.openhab.org/docs/configuration/jsr223.html to install a rule is to use
automationManager
and thus to import the RuleSupport preset, this preset has always to be included explicitly by the caller. The other items from the preset are not strictly necessary, as they can be obtained byimport
s. (And the imports are required to move as much code in Groovy as possible under the TypeChecked and CompileStatic annotations).The text was updated successfully, but these errors were encountered: