openhab-docs/_transformations/javascript
John Cocula 917f13ce60 [Add-ons] Add transformation docs (#357)
Signed-off-by: John Cocula <john@cocula.com>
2017-03-02 16:13:47 +01:00
..
readme.md [Add-ons] Add transformation docs (#357) 2017-03-02 16:13:47 +01:00

readme.md

id label title type description since install
javascript JavaScript JavaScript - Transformations transform Transform an input to an output using JavaScript. 2x auto

{% include base.html %}

JavaScript Transformation Service

Transform an input to an output using JavaScript.

It expects the transformation rule to be read from a file which is stored under the transform folder. To organize the various transformations, one should use subfolders.

Example

Let's assume we have received a string containing foo bar baz and we're looking for a length of the last word (baz).

transform/getValue.js:

(function(i) {
    var array = i.split(" ");
    return array[array.length - 1].length;
})(input)