Rollershutter Rule from DSL to JSS

Has somebody already found out how to use “receivedCommand” inside a JSS rule in the UI? From old ECMA tutorials it should be “command” but the UI does not know how to proceed. Additionally would be nice how achieve the same behavior: “instanceof Number” in JSS.

Thanks for your help!

Thats the old DSL rule:

rule "Rollershutter"
    Item Sonoff15_rollershutter received command   
        if(!(receivedCommand instanceof Number)){
        switch receivedCommand 
            case DOWN : Sonoff15_Number.sendCommand(0)
            case UP : Sonoff15_Number.sendCommand(100)
            default : {}
        val Number rollershutter = Sonoff15_rollershutter as DecimalType).intValue

New JS-Rule:

switch (String(event.itemCommand)){
  case "DOWN" : items.getItem("Sonoff15_Number").sendCommand("0")
  case "UP" : items.getItem("Sonoff15_Number").sendCommand("100")
  case "STOP" : items.getItem("Sonoff15_ShutterStop").sendCommand("STOP")

Good question. Trying to find out myself, too, at the moment.

So far I only understand that you have the triggeringItem name and state available within the following:


However, I thought that event is JSR223, and not new JSscripting.
Let’s see, when the expert are coming up what they say.

For old JS see here:

console.log("receivedCommand: ", event.itemCommand);
console.log("triggeringItemName: ", event.itemName);

works also with “new” JS

Hello Oliver,

I was dealing with a similar issue wanting to access the receivedCommand for an ItemCommandTrigger and stumbled upon this thread. Unfortunately my very simple rule fails to execute. Here’s the code:

var {event, items, log, rules, triggers} = require("openhab")

let logger = log("tests");

    name: "[TESTING] Test Switch Received Command",
    description: "Log the item name, state and received command",
    triggers: [
    execute: data => {
        let itemName = event.itemName;

I’m running openhab 3.2.0.M2 in a Docker container on a Raspberry Pi 3 running raspbian lite. I have configured the JSScriping Extension through Main UI to not use built-in variables. Any idea why this doesn’t work?

you are declaring a variable (itemName) but you are not doing anything with it.
If you write it into your log, what happens?

It produced an error with only that statement. I have elaborated further in this post. I was accessing an undefined variable, that problem is fixed now. Unfortunately, that the property of that variable I’m trying to access is somehow undefined and I have no idea why.

in the other post Rich advised to change var into const.
I would try without imports anyway first.

The problem was much deeper than expected but I found a solution which I have described in detail as a reply to my other post. I’ll just leave the link here in case anyone stumbles upon this post while dealing with a similar issue.