Closed JacekKac closed 2 years ago
in addition i was able to do it in
scriptExtension.importPreset("RuleSupport");
scriptExtension.importPreset("RuleSimple");
var sRule = new SimpleRule() {
execute: function(module, input) {
print("input:" + input); // input contains all the output values
}
};
sRule.setName('PWM' + RadiatorACx);
sRule.setTags(java.util.Set.of("PWM"));
sRule.setTriggers([
TriggerBuilder.create()
.withId(RadiatorACx)
.withLabel(RadiatorACx)
.withTypeUID("pwm.trigger")
.withConfiguration(
new Configuration({
"deadManSwitch" : RadiatorACx + '_PWM_deadManSwitch',
"minDutycycle" : RadiatorACx + '_PWM_minDutycycle',
"dutycycleItem" : RadiatorACx + '_PWM_dutycycleItem',
"interval" : RadiatorACx + '_PWM_interval',
"maxDutycycle" : RadiatorACx + '_PWM_maxDutycycle'
})).build()
]);
sRule.setActions([
ActionBuilder.create()
.withId("1")
.withTypeUID("core.ItemCommandAction")
.withConfiguration(
new Configuration({
"itemName" : RadiatorACx + '_Relay'
})).build()
]);
automationManager.addRule(sRule);
any idea how to do this ? it's urgent for me
Yes, I have an idea, I am taking a look into this at the moment.
Hello @JacekKac,
I have a solution, two PRs are open now. I have to wait for @digitaldan for review, but I can give you some impression hot it will work:
rules.JSRule({
name: "Termostat x PWM rule",
triggers: [
triggers.PWMTrigger('pwm_dimmer', 10)
],
execute: (event, input) => {
items.getItem('pwm_switch').sendCommand(input.command.toString());
}
});
Hi, i need your help with syntax for PWM and / or PID controller rule creation using JSRule.