Openhab 2 jsr223 with groovy

I’m using latest docker snapshot image with jsr223 support and I’m trying to move all my groovy code to openhab2.

My first test is

scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleSimple")
class myRule extends SimpleRule {
    def execute(self, module, inputs) {
    }
}

but fails with

Script5.groovy: 6: unable to resolve class SimpleRule 
 @ line 6, column 1.
   class myRule extends SimpleRule {

I see that rule bundle puts SimpleRule.class as type

staticTypes.put("SimpleRule", SimpleRule.class);

but I’cant extend this type in groovy. I try to import import org.eclipse.smarthome.automation.module.script.rulesupport.shared.simple.SimpleRule but groovy can’t resolve class.

Someone knows how to make scripts in groovy for openhab2 ? I have a lot of scripts working with Openhab1 in groovy and I don’t want to migrate to Jhyton or Javascript …

1 Like

I ran into the same issue and created the following issue for it:

1 Like

Great, hope this can be solved.