Skip to content

Commit

Permalink
Added docs for missing core actions (openhab#769)
Browse files Browse the repository at this point in the history
Added description for executeCommandLine, callScript, and transform Actions. 

Addresses openhab#768 

Signed off by Rich Koshal <[email protected]>
  • Loading branch information
rkoshak authored and Confectrician committed Sep 1, 2018
1 parent df1a5d2 commit 75b3554
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions addons/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ They can be found in the article about [openHAB multimedia]({{base}}/configurati

One can configure whether specific log entries are logged out and where they get logged to (e.g. to a separate file) by [editing the logger configuration]({{base}}/administration/logging.html).

### Exec Actions

- `executeCommandLine(String commandLine)`: Executes a command on the command line without waiting for the command to complete
- `executeCommandLine(String commandLine, int timeout)`: Executes a command on the command and waits timeout milliseconds for the command to complete, returning the output from the command as a String

Note: The commandLine variable often has to use a special format where @@ needs to be used in place of spaces. For example the bash command touch somefile will have to be written as touch@@somefile.

### HTTP Actions

- `sendHttpGetRequest(String url)`: Sends an GET-HTTP request and returns the result as a String
Expand Down Expand Up @@ -109,6 +116,21 @@ if ((thingStatusInfo != null) && (thingStatusInfo.getStatus().toString() == "ONL
}
```

### openHAB Subsystem Actions
openHAB has several subsystems that can be accessed from Rules. These include persistence, see [Persistence Extensions in Scripts and Rules]({{base}}/configuration/persistence.html#persistence-extensions-in-scripts-and-rules), transformations, and scripts.

- `callScript(String scriptName)`: Calls a script which must be located in the config/scripts folder.

Scripts are small pieces of Rules DSL code that can be called from Rules.
However, Scripts have limitations.
Scripts cannot accept arguments.
Scripts cannot return a value.
Any reference to a class that would normally need to be imported in a .rules file, the class needs to be referred to by its full package as imports are not supported.

- `transform(String type, String function, String value)`: Applies a transformation of a given type with some function to a value and returns the transformed value as a String or the original value if the transformation failed.

See [Transformations]({{base}}/configuration/transformations.html#usage) for available transformations and their usage.

## Cloud Notification Actions

Notification actions may be placed in Rules to send alerts to mobile devices registered with an [openHAB Cloud instance](https://github.com/openhab/openhab-cloud) such as [myopenHAB.org](https://myopenhab.org).
Expand Down

0 comments on commit 75b3554

Please sign in to comment.