openhab-addons/bundles/org.openhab.transform.jinja
Holger Friedrich f479a38337
Upgrade Karaf from 4.4.6 to 4.4.7 (#17515)
* Upgrade Karaf from 4.4.6 to 4.4.7

* Sync runtime dependencies with Karaf 4.4.7, most notably:
   * PaxWeb 8.0.30
   * Jetty 9.4.57.v20241219
   * BouncyCastle 1.78.1
   * CXF 3.6.4
   * Jackson 2.18.2
   * JNA 5.16.0
   * JAXB 2.3.9
   * commons-io 2.17.0
   * commons-lang3 3.17.0
   * commons-logging 1.3.4
   * ASM 9.7.1
   * PaxLogging 2.2.8
 * Resolve itest runbundles

* Adapt to core change, xtext dependencies

* gson 2.11.0
* guava 3.33.1
* ecj 3.39.0
* Fix newly introduced compilation and test issues in bindings

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
2025-01-26 15:47:37 +01:00
..
src Start license headers with `/*` instead of `/**` (#18061) 2025-01-07 22:33:03 +01:00
NOTICE [jinja] Use osgiified Jinjava (#17356) 2024-09-01 12:51:05 +02:00
README.md Multiple binding markdown fixes (#17422) 2024-09-28 17:46:53 +02:00
noEmbedDependencies.profile [transform.jinja] Properly use jinjava OSGi (#17358) 2024-09-04 23:07:21 +02:00
pom.xml Upgrade Karaf from 4.4.6 to 4.4.7 (#17515) 2025-01-26 15:47:37 +01:00

README.md

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 a 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