Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usage information for openhab transformations #134

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,21 @@ end

### Transformations

#### Using openHAB Transformations <!-- omit from toc -->

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.
jimtng marked this conversation as resolved.
Show resolved Hide resolved

```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 <!-- omit from toc -->

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`.
Expand Down