Send value to command in a UI rule

I was hoping I could do this using a rule that calls a command and keep it nice and simple. But it doesn’t seem to work;

It’s not possible to pass the state from the trigger item into the command? You need you write another script again to do this?

You can’t with basic UI actions. You’ll have to use a Script Action. It’s a one liner though, but what that one line in depends on the language you choose.

Rules DSL: nxpanel_command.sendCommand(newState);


ECMAScript 5.1: events.sendCommand('nxpanel_command', event.itemState.toString());

ECMAScript 2021: items.getItem('nxpanel_command').sendCommand(event.itemState.toString());

Ok, had a feeling it might not. easier enough to do in a rule, just that’s such simple little use case; it would be good if that was possible though. an item changes doing something else with the value. would be useful and same a lot on one-liner rules that are not really needed.

I want to caution you about the use of terminology to avoid confusion in the future.


Is a Rule.


are examples of Actions. Actions are a part of a Rule. They don’t exist independently from the rule. Creating a one liner Script Action is no more time consuming and takes up no more space or room in OH than defining a simple UI action.

You aren’t saving anything by using a UI Action compared to a Script Action. All they are are different ways to define what the rule should do when triggered.

Kind of agree. But, you could have no options at all for action other than a script, and do it all in a script. But that’s not how it works. When you section action, you pick a number of predefined useful things, that avoid you having to drop that extra level to a script. In the view I had initially, you can clearly see on the screen what that trigger is and that happens if it’s triggered. That’s nice, and different, and to me is a saving. You don’t need to open the script to see what it does in one line, then jump back to rules again. So in the same way there are direct actions for other things, it would certainly seem to have merit to have one that let you pass the trigger value to a command, just like all the other short cut action. Certainly valid and certainly a saving, how big and important that is, is another question. But I think it would be useful.

If you are referring to the separate section Scripts in MainUI… I have news for you. Those are Rules too. They are just a special type of rule consisting of a single Script Action (no triggers, no conditions) tagged with “Script”. That would indeed add lots of extra rules floating around, but that would be kind of an awkward and pointless way to configure it. If you have an Action Script only used by one rule, make it part of that rule. Don’t create a separate rule to be called.

When you create the Script Action…

You can (and I encourage you to) enter meaningful information in those top two fields. If you fail to do so, you can get back to those fields by clicking the little edit icon to the right of the Action.


MainUI can’t figure out what to put there automatically so you’d have to enter something meaningful.

If it were easy to implement it would have been implemented already. And at some point there has to be a line drawn between what is supported with the simple UI actions and when a Script Action needs to be used. I don’t know where that line is. I’m inclined to side on pushing users to Script Actions sooner rather than later but that’s not my call.

All valid points. Always good to get feedback from experts that have been using it a long time.
Thank you.

And, because this might be an XY Problem, there are a couple of other ways you can achieve this.

  1. The Follow Profile, no rule required. Items | openHAB

  2. The Debounce rule template on the marketplace, no coding required but you will have to add Item metadata. To get a straight passthrough, just use ‘0s’ as the debounce time. Debounce