Hello,
I’ve implemented a binding that contains an action class with static methods. They return a custom builder to create a configuration and apply it.
Now I’m facing problems when I try to use it from rules. The static method is called and returns the builder (verified in debugger), but I can’t call any method of the builder in the rule.
import org.openhab.binding.tado.TadoActions
import org.openhab.binding.tado.internal.TadoHvacChange
rule "Back to schedule"
when
Item BackToScheduleRule received command ON
then
TadoActions.tadoHvacChange("tado:zone:demo:heating").followSchedule().apply()
BackToScheduleRule.postUpdate(OFF)
end
fails with error message
Rule 'Back to schedule': An error occurred during the script execution: The name '<XMemberFeatureCallImplCustom>.followSchedule()' cannot be resolved to an item or type.
But everything is working fine in JSR223 with a Javascript rule
'use strict';
scriptExtension.importPreset("RuleSupport");
scriptExtension.importPreset("RuleSimple");
var tadoActions = Java.type("org.openhab.binding.tado.TadoActions");
var sRule = new SimpleRule() {
execute: function( module, input) {
tadoActions.tadoHvacChange("tado:zone:demo:heating").followSchedule().apply();
events.postUpdate("BackToScheduleJS", "OFF");
}
};
sRule.setTriggers([
new Trigger(
"backToScheduleTrigger",
"core.ItemCommandTrigger",
new Configuration({
"itemName": "BackToScheduleJS",
"command": "ON"
})
)
]);
automationManager.addRule(sRule);
It looks like the rule knows the action class, but not the returned class org.openhab.binding.tado.internal.TadoHvacChange
.
Can you please help me resolving the issue?
I’d be fine with using JSR223, but it’s a public binding, so both ways should work.
Thanks you very much!