Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Groovy] Default preset does not include OnOffType #17247

Closed
dilyanpalauzov opened this issue Aug 13, 2024 · 3 comments · Fixed by #17383
Closed

[Groovy] Default preset does not include OnOffType #17247

dilyanpalauzov opened this issue Aug 13, 2024 · 3 comments · Fixed by #17383
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@dilyanpalauzov
Copy link
Contributor

https://www.openhab.org/docs/configuration/jsr223.html#default-preset-importpreset-not-required says that the OnOffType is available in Groovy, as part of the Default preset.

I create a file in openhab/automation/jsr223/onoff.groovy with content:

OnOffType v = ON

Loading it fails:

2024-08-12 20:53:31.386 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/etc/openhab/automation/jsr223/onoff.groovy': org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/etc/openhab/automation/jsr223/onoff.groovy: 2: unable to resolve class OnOffType
 @ line 2, column 11.
   OnOffType v = ON
             ^

1 error

If I change onoff.groovy to:

import org.openhab.core.library.types.OnOffType
OnOffType v = ON

there is no error on loading.

So in OpenHAB 4.2.1 the Default preset for Groovy does not include OnOffType, contrary to the statement at https://www.openhab.org/docs/configuration/jsr223.html#default-preset-importpreset-not-required.

@dilyanpalauzov dilyanpalauzov added the bug An unexpected problem or unintended behavior of an add-on label Aug 13, 2024
@lsiepel
Copy link
Contributor

lsiepel commented Aug 13, 2024

Are you aware of the last version that worked? Maybe @wborn can comment as most groovyscripting PR’s are his. I’m also interested in how this mechanism is setup, to provide future support

@dilyanpalauzov
Copy link
Contributor Author

Are you aware of the last version that worked?

No, this is the first version I tried (OH 4.2.1).

wborn added a commit to wborn/openhab-addons that referenced this issue Sep 7, 2024
This allows for removing many imports from scripts which results in less code.

Fixes openhab#17247

Signed-off-by: Wouter Born <github@maindrain.net>
wborn added a commit to wborn/openhab-addons that referenced this issue Sep 7, 2024
This allows for removing many imports from scripts which results in less code.

Fixes openhab#17247

Signed-off-by: Wouter Born <github@maindrain.net>
@wborn
Copy link
Member

wborn commented Sep 7, 2024

I don't think it ever worked but I figured out a way for importing these additional classes in scripts with #17383.

@lsiepel lsiepel closed this as completed in d161354 Sep 8, 2024
digitaldan pushed a commit to digitaldan/openhab-addons that referenced this issue Sep 24, 2024
This allows for removing many imports from scripts which results in less code.

Fixes openhab#17247

Signed-off-by: Wouter Born <github@maindrain.net>
pgfeller pushed a commit to pgfeller/openhab-addons that referenced this issue Sep 29, 2024
This allows for removing many imports from scripts which results in less code.

Fixes openhab#17247

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Patrik Gfeller <patrik.gfeller@proton.me>
joni1993 pushed a commit to joni1993/openhab-addons that referenced this issue Oct 15, 2024
This allows for removing many imports from scripts which results in less code.

Fixes openhab#17247

Signed-off-by: Wouter Born <github@maindrain.net>
matchews pushed a commit to matchews/openhab-addons that referenced this issue Oct 18, 2024
This allows for removing many imports from scripts which results in less code.

Fixes openhab#17247

Signed-off-by: Wouter Born <github@maindrain.net>
cipianpascu pushed a commit to cipianpascu/openhab-addons that referenced this issue Jan 2, 2025
This allows for removing many imports from scripts which results in less code.

Fixes openhab#17247

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants