I would like to replace a rule by an item definition :
This rule :
Rule "begin your execution"
when
Item YourTrigger changed
then
if(YourTrigger.state == ON){
yourcommand_Args.sendCommand("Additional Argument to command line for ON")
}else{
yourcommand_Args.sendCommand("Additional Argument to command line for OFF")
}
yourcommand_Run.sendCommand(ON)
end
By an item like this :
Switch yourcommand_Args {channel="exec:command:yourcommand:input", Additional Argument to command line for ON, Additional Argument to command line for OFF}
I would like to run it directly when input change by on or off switching button.
Is it possible ?
My thing is something likes that :
You can -
set up your exec command Thing to “autorun”
set up your exec command to accept parameter from input channel
Link a String Item to exec input channel.
Put that item on your Sitemap with a Switch widget.
Im not sure to understand your solution because it looks like my actual situation.
I want that %2$s be inside my item’s file or sitemap’s file and not in my rule’s file.
That 's your explanation ?
Yes. Which part don’t you understand? Can you show us whereyou’re having trouble?
Can you create an exec command Thing with your command line, and a placeholder for your parameter?
Can you set that Thing to autorun?
Can you create a Text type Item?
Can you link that Item to your Thing’s input channel?
Can you display that Text Item on your sitemap with a Switch widget, with mappings for “apple” and “banana” or whatever your parameter needs to be?
When the poke the UI button, it will command “apple” to your Item. That is linked to exec’s input channel, so “apple” will be used instead of %2s in your exec command. Autorun will make it execute.
I think I can use this (like the tutorial) :
switch triggeringItem.name {
case “first pdu off” : controlPduInput.sendCommand (t282-gude04 1 0) //for OFF
case “first pdu on” : controlPduInput.sendCommand (t282-gude04 1 1) //for ON
case “second pdu” : controlPduInput.sendCommand (t282-gude05 1 0)…
}
It’s hard to understand. rossko57 gave you a step by step approach to achieve this without using Rules and asked you to specifically tell him at which step you have difficulty so we can help. Instead of doing that you jump back to doing it in Rules.
It’s really hard to help if you jump around like that.
items :
String controlPdu1Port2 “ON / OFF PDU 1 Port 2” {channel=“exec:command:controlPdu:input”}
String controlPduInput “[%s]” {channel=“exec:command:controlPdu:input”}
Switch controlPduRun {channel=“exec:command:controlPdu:run”} (i think I can delete this line )
Dear all,
I have always an issues with %2$s
I need to give a parameter to a string item without sitemap.
Is it possible to create a switch item, when I click on this item, it gives a parameter to string item link to a thing ? Not by sitemap
Because I have somes computers to shutdown, I have an exec binding with shutdown command and parameter. The parameter has to be the hostname of my computer. I would like to create a switch item with the hostname in parameter.
Thanks
If using the sitemap, this is super easy. Just use a Switch element with mappings. That will create buttons and when you click the button it will send the name of the host as a command to the String Item being displayed.
Hello
I have a scheduler for each morning and night and sometimes I click on sitemap.
Second solution is to do one thing declaration for each command and one switch link to the thing.
In additional of this problem, with openhab 3 I can not use classic ui, i have to do a new interface .
Ok i do your solution, one rule by item, it’s easiest and more logic.
Thanks for you help, i don’t need exec binding old version with this solution.
Regards
Dear all,
I have a new problem, I have an exec thing
I use this rule to send multiple order to my exec thing :
rule " control Pdu"
when
Member of gPdu received command
then
val i = triggeringItemName.toString.length;
val pduName = triggeringItemName.substring(0, i - 1)
val pduPort = triggeringItemName.substring(i - 1,i)
val pduOrder = pduName + ’ ’ + pduPort + ’ ’ + receivedCommand
controlPdu_Args.sendCommand(pduOrder)
end`
in my script i do gPdu.sendCommand(OFF)
it should send 4 pduOrder different, but only one or two are send
i think i need to do one instance by item
if I click one by one on the 4 items it works, but 4 simultaneously (by a group send command) doens’t work