How to make a custom button with an sh command?

how to create a button with an sh command?
i want to use this command for example 9999 on
i had installed exec binding
can you help me to use it to make a button to execute the script ?
thank you


just try this:

For a pushbutton you can just set your switch back to “OFF” at the end of your rule


can you tell me exactly what should i put please? and where items? maps ? things?


do you have already some experience with OpenHAB?


I have not tried by myself, but this way should work:

  1. First activate the binding “exec” in Paper UI
  2. configure item like this
Switch   button  { exec="ON:'some command'"}

then you must set up a rule to turn the switch back OFF in a button.rules file:

rule "button off"
        Item button changed from OFF to ON

To get a button instead of a switch, use mappings in the sitemap in combination with autoupdate=“false”.

Switch MyButton "My Button" {exec="ON:'some command'",autoupdate="false"}


Switch item=MyButton mappings=[ON="GO!"]

This would draw a button instead of a switch, the button will be labeled “GO!”. No need for resetting the button, as autoupdate="false" prevents OH to update the state of the underlying switch.
You could also draw more than one button (especially when using a Number item):

Switch item=MyNumberButton mappings=[1="One",2="Two",3="Three"]

i have done it thank you
but theproblem is that open hab dont know the status of the switch if it on or off anyway to make this done ? and the swtich on openhab move to on even if the switch in real life is disconnected