openhab-addons/bundles/org.openhab.transform.jinja
openhab-bot 598d88648c
New Crowdin updates (#12849)
* New translations boschshc.properties (German)
* New translations jinja.properties (German)
* New translations regex.properties (German)
* New translations jsonpath.properties (German)
* New translations xpath.properties (German)
* New translations dynamodb.properties (German)
* New translations jdbc.properties (German)
* New translations neeo.properties (German)
* New translations fsinternetradio.properties (German)
* New translations sonyaudio.properties (German)
* New translations systeminfo.properties (German)
* New translations wemo.properties (German)
* New translations googlestt.properties (German)
* New translations voicerss.properties (German)
* New translations porcupineks.properties (German)
* New translations watsonstt.properties (German)
* New translations voskstt.properties (German)
* New translations deutschebahn.properties (German)
* New translations dwdunwetter.properties (German)
* New translations shelly.properties (German)
* New translations googletts.properties (German)
* New translations http.properties (Italian)
* New translations evcc.properties (German)
* New translations imperihome.properties (Italian)
* New translations voicerss.properties (German)
* New translations dwdunwetter.properties (German)
2022-06-01 12:11:04 +02:00
..
src New Crowdin updates (#12849) 2022-06-01 12:11:04 +02:00
NOTICE added migrated 2.x add-ons 2020-09-21 03:37:19 +02:00
pom.xml pom update from http to https reference (#11833) 2021-12-23 19:40:44 +01:00
README.md Update README.md (#12168) 2022-02-05 20:44:45 +01:00

Jinja Transformation Service

Transforms a value using a jinja template.

The main purpose of this transformer is the use in the home assistant discovery. Therfore not all features of the home assistant templating are supported. Basically on Processing incoming data

Available variables

Variable Description
value The incoming value.
value_json The incoming value parsed as JSON.

Examples

Basic Examples

Incoming data

Given the value

{"Time":"2019-01-05T22:45:12","AM2301":{"Temperature":4.7,"Humidity":93.7},"TempUnit":"C"}

the template

{{value_json['AM2301'].Temperature}}`

extracts the string 4.7.

Outgoing data

The JINJA transformation can be used to publish simple JSON strings through, for example, the HTTP Binding's commandTransformation parameter.

Say we have an String Item which holds the following value:

This is my string

Adding the following into the commandTransformation parameter of your HTTP Thing Channel

JINJA:{"msgtype":"m.text", "body":"{{value}}"}

will send the following string out of openHAB

{"msgtype":"m.text", "body":"This is my string"}

{{value}} will be replaced by whatever the value of your Item is.

Note that if using *.things files you must escape quotation marks, for example:

commandTransformation = "JINJA:{\"msgtype\":\"m.text\", \"body\":\"{{value}}\"}"

Further Reading