Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Transformations

Ma-580 edited this page Sep 28, 2014 · 22 revisions

Overview of available transformation services

Exec transformation service

tbd ...

Java Script transformation service

OpenHab supports transformation scripts written in Javascript. Example item configuration:

http="<[http://example.com/var/value:60000:JS(getValue.js)]" }

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

getValue.js:

// Wrap everything in a function
(function(i) {
    var
        array = i.split(i);
    return array[array.length - 1].length;
})(input)
// input variable contains data passed by openhab

Map transformation service

tbd ...

RegEx transformation service

tbd ...

XPath transformation service

tbd ...

XSLT transformation service

tbd ... For samples see here.

JSonPath transformation service

As with XPath on XML data, JSONPath allows direct query of JSON data.

// Test JSONPath
rule "Test JSONPath"
when Time cron "0 * * * * ?"
then
   var String json = '{"store":{"book":[{"category":"reference","author":"Nigel Rees","title": "Sayings of the Century", "price": 8.95  } ],  "bicycle": { "color": "red",  "price": 19.95} }}' 
    var test = transform("JSONPATH","$.store.book[0].author",json)
    println(test)
end

Installation


User Interfaces


Community

(link to openHAB forum)

Development



Misc


Samples

A good source of inspiration and tips from users gathered over the years. Be aware that things may have changed since they were written and some examples might not work correctly.

Please update the wiki if you do come across any out of date information.

Use case examples

Collections of Rules on a single page

Single Rules

Scripts


Release Notes

Clone this wiki locally