Hello everyone,
I finally started migrating my old openHAB 2.5 installation to the latest Milestone build of openHAB 3. I’m currently running openHAB in a docker container pulled from openhab/openhab:milestone
. Docker is running on a Raspberry Pi 3 Model B Rev 1.2
with the OS Debian GNU/Linux 11 (bullseye)
.
I have multiple rules from openHAB 2.5, using the Rules DSL, that access the implicit variable receivedCommand
. I’m trying to replicate that behavior using file-based Javascript rules with the JSScripting Addon and can’t get it to work. Researching this forum I stumbled upon this thread which mentioned the event.itemCommand
statement should provide the same functionality.
I’ve tried testing this with a very simple rule:
var {event, log, rules, triggers} = require("openhab")
let logger = log("tests");
rules.JSRule({
name: "[TESTING] Test Switch Received Command",
description: "Log the item name, state and received command",
triggers: [
triggers.ItemCommandTrigger("testSwitch")
],
execute: data => {
let cmd = event.itemCommand;
}
});
Unfortunately this rule only produces the following error messages when I flip testSwitch
in a sitemap:
Failed to execute rule '-TESTING--Test-Switch-Received-Command-5e7c8d4a-5f10-4e4b-b988-ff9b2f8f43b4': Fail to execute action: 1
Since the only execution statement of the rule is a variable assigment from event.itemCommand
I assume that statement is not working as expected.
For anyone wondering why I’m requiring openhab, it’s because I have configured JSScripting to not use the built-in variables via the Main UI.
Any help would be appreciated. I’m also interested in replicating the triggeringItem
functionality from the rules dsl. Apparently this should work using event.itemName
or event.item
. Unfortunately using those statement produce the same error message as above.