Using openhabian 1.4 and openhab 2.2, I am currently trying to migrate my openHAB 1.8.x groovy rules.
I found that it is impossible to subclass SimpleRule like that:
import org.eclipse.smarthome.automation.*
import org.eclipse.smarthome.automation.module.script.rulesupport.shared.simple.*
import org.eclipse.smarthome.config.core.Configuration
import org.slf4j.*
scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleSimple")
def logger = LoggerFactory.getLogger('Holiday.groovy')
class HolidayRule extends SimpleRule {
Object execute(Action module, Map<String, ?> inputs) {
logger.warn("Separate class")
}
}
def holidayRule1 = new HolidayRule()
holidayRule1.setTriggers(...)
automationManager.addRule(holidayRule1)
This leads to
date/time [ERROR] [.automation.core.internal.RuleEngine] - Failed to execute rule '1612de53-1b98-431b-b826-cf0c5a3051ce': Fail to execute action: 1
Using an anonymous subclass instead works just fine.
What am I missing?