From 45c34f55a909292180f6b5336d2fa88dd60d22b4 Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Mon, 4 Sep 2023 14:57:42 +1000 Subject: [PATCH] Add usage information for openhab transformations Signed-off-by: Jimmy Tanagra --- USAGE.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/USAGE.md b/USAGE.md index 6734013efc..f18041aa1f 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1252,6 +1252,21 @@ end ### Transformations +#### Using openHAB Transformations + +Although it can often be done better and more easily in native Ruby code, existing openHAB transformations +such as MAP, JSONPATH, Jinja Transformation, or even Ruby transformation written in the `/transform` folder +can also be used by calling the {OpenHAB::DSL.transform transform} method. + +```ruby +# Convert OPEN/CLOSED to Online/Offline using availability.map +# OPEN=Online +# CLOSED=OFFLINE +logger.info transform(:map, "availability.map", LivingRoom_Switch_Availability.state) +``` + +#### Writing Custom Transformations in Ruby + This add-on also provides the necessary infrastructure to use Ruby for writing [transformations](https://www.openhab.org/docs/configuration/transformations.html). The main value to be transformed is given to the script in a variable called `input`.