triggeringChannel equivalent in ECMAScript

Hi,

I have a physical switch with four buttons and currently four rules to handle the button presses.

Now I want to create one rule per switch that triggers for all four buttons. As “Then” I use ECMAScript. How do I know which button has been pressed? I’d like to have something like

switch (trigger) {
  case 'top-left':
    # top left button has been pressed
    break;
  case 'top-right':
    # top rightbutton has been pressed
    break;
....
}

For the old school rules there’s the keyword triggeringChannel , but is there an equivalent in ECMAScript?

There are the three events that you can use. Not sure how you detect which button has been pressed as I don’t know the setup of your button:

event.itemName

event.channel

event.event

In some of my things it is even a particular channel that tells me which button was pressed by providing a scene number.

Thanks. Is there a place to look up such things?

Yes, here: GitHub - openhab/openhab-js: openHAB JavaScript Library for JavaScript Scripting Automation

1 Like