openhab-docs/_addons_bindings/exec
Thomas Dietrich 826ef4abb4 Distinguish collections, improve update process (#514)
* Rename collection folders

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Change all occurences of addons and repos

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Add further corrections

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Remove temporary directories after processing

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Reduce addons menus, show current uncond.

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Fix typo

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Remove redundant addons from permalinks

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Sort UI menu entries correctly

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>

* Split maven command

Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>
2017-09-22 21:05:09 +02:00
..
readme.md Distinguish collections, improve update process (#514) 2017-09-22 21:05:09 +02:00

readme.md

id label title type description since install
exec Exec Exec - Bindings binding This binding integrates the possibility to execute arbitrary shell commands. 2x auto

{% include base.html %}

Exec Binding

This binding integrates the possibility to execute arbitrary shell commands.

Supported Things

Currently, the binding supports a single type of Thing, being the command Thing.

Binding Configuration

The binding does not require any specific configuration.

Note that the commands are executed in the context and with the privileges of the process running the java virtual machine. It is not advised to run the virtual machine as superuser/root.

Thing Configuration

The command Thing requires the command to execute on the shell. Optionally one can specify:

  • a transformation to apply on the execution result,
  • an interval, in seconds, the command will be repeatedly executed,
  • a time-out, in seconds, the execution of the command will time out, and lastly,
  • a boolean parameter to make the command execute immediately every time the state of the input channel has changed.

For each command a separate Thing has to be defined.

Thing exec:command:apc [command="/usr/local/bin/apcaccess  status", interval=15, timeout=5, autorun=false]

command itself can be enhanced using the well known syntax of the java.util.Formatter class. The following parameters are automatically added:

  • the current date (as java.util.Date, example: %1$tY-%1$tm-%1$td)
  • the current State of the input channel (see below, example: %2$s)

Channels

All Things support the following channels:

Channel Type ID Item Type Description
input String Input parameter to provide to the command
output String Output of the last execution of the command
exit Number The exit value of the last execution of the command
run Switch Send ON to execute the command and the current state tells whether it is running or not
lastexecution DateTime Time/Date the command was last executed, in yyyy-MM-dd'T'HH:mm:ss.SSSZ format

Full Example

demo.things

Thing exec:command:apc [command="/usr/local/bin/apcaccess  status", interval=15, timeout=5]
Thing exec:command:myscript [command="php ./configurations/scripts/script.php %2$s", transform="REGEX((.*?))"]

demo.items

String APCRaw "[%s]" (All) {channel="exec:command:apc:output"} 
Switch APCRunning { channel="exec:command:apc:run"}
Number APCExitValue {channel="exec:command:apc:exit"}
DateTime APCLastExecution {channel="exec:command:apc:lastexecution"}