openhab / openhab-js

openHAB JavaScript Library for JavaScript Scripting Automation
https://www.openhab.org/addons/automation/jsscripting/
Eclipse Public License 2.0
38 stars 31 forks source link

PWM - bad syntax of execute #135

Closed JacekKac closed 2 years ago

JacekKac commented 2 years ago

There is sth wrong with the execute part i took it from your docs @florian-h05

rules.JSRule({
    name: `Termostat ${i} PWM rule`,
    id: `Termostat_${i}_PWM_rule`,
    tags: [`Room${i}`, `_DYNAMIC_`],
    overwrite: `true`,
    description: `PWM automation `,
    triggers: [triggers.PWMTrigger(`RadiatorAC${i}_PWM_dutycycleItem`,items.getItem(`RadiatorAC${i}_PWM_interval`).state, items.getItem(`RadiatorAC${i}_PWM_minDutycycle`).state, items.getItem(`RadiatorAC${i}_PWM_maxDutycycle`).state, items.getItem(`RadiatorAC${i}_PWM_deadManSwitch`).state)],
      execute: (event, input) => {
        items.getItem(`RadiatorAC${i}_PWM_Relay`).sendCommand(**input.command.toString()**);
    }});

2022-06-06 19:59:58.935 [ERROR] [tomation.script.file.rulesCreator.js] - Failed to execute rule Termostat_1_PWM_rule: TypeError: Cannot read property "command" from undefined: TypeError: Cannot read property "command" from undefined at execute (rulesCreator.js:123) at doExecute (/etc/openhab/automation/node_modules/openhab/rules/rules.js:239) 2022-06-06 19:59:58.941 [WARN ] [e.automation.internal.RuleEngineImpl] - Fail to execute action: 1 org.graalvm.polyglot.PolyglotException: Error: Failed to execute rule Termostat_1_PWM_rule: TypeError: Cannot read property "command" from undefined: TypeError: Cannot read property "command" from undefined at execute (rulesCreator.js:123) at doExecute (/etc/openhab/automation/node_modules/openhab/rules/rules.js:239) at .doExecute(/etc/openhab/automation/node_modules/openhab/rules/rules.js:250) ~[?:?]

florian-h05 commented 2 years ago

Please retry with the example from here: https://openhab.github.io/openhab-js/triggers.html#.PWMTrigger

JacekKac commented 2 years ago

thx! working OK