openhab-addons/bundles/org.openhab.transform.map
openhab-bot c23f6adf13
New Crowdin updates (#11832)
* New translations astro.properties (Finnish)
* New translations astro.properties (German)
* New translations bluetooth.properties (German)
* New translations boschshc.properties (Italian)
* New translations comfoair.properties (German)
* New translations dwdunwetter.properties (German)
* New translations epsonprojector.properties (German)
* New translations gpio.properties (German)
* New translations heliosventilation.properties (German)
* New translations homeconnect.properties (German)
* New translations homematic.properties (German)
* New translations ipp.properties (German)
* New translations jruby.properties (Hungarian)
* New translations jsscripting.properties (German)
* New translations jsscripting.properties (Hungarian)
* New translations map.properties (German)
* New translations map.properties (Hungarian)
* New translations mqttbroker.properties (Italian)
* New translations nanoleaf.properties (German)
* New translations ocean.properties (German)
* New translations openhabcloud.properties (Finnish)
* New translations samsungtv.properties (Hungarian)
* New translations shelly.properties (German)
* New translations snmp.properties (German)
* New translations sonos.properties (German)
* New translations spotify.properties (German)
* New translations tr064.properties (German)
* New translations tradfri.properties (German)
* New translations unifi.properties (German)
* New translations unifi.properties (Hungarian)
* New translations valloxmv.properties (Finnish)
* New translations volvooncall.properties (German)
* New translations xslt.properties (German)
2021-12-29 13:16:52 +01:00
..
conf/transform/map added migrated 2.x add-ons 2020-09-21 03:37:19 +02:00
src New Crowdin updates (#11832) 2021-12-29 13:16:52 +01:00
NOTICE added migrated 2.x add-ons 2020-09-21 03:37:19 +02:00
README.md [transform.map] Update README.md (#11439) 2021-10-24 12:27:59 +02:00
pom.xml pom update from http to https reference (#11833) 2021-12-23 19:40:44 +01:00

README.md

Map Transformation Service

Transforms the input by mapping it to another string. It expects the mappings to be read from a file which is stored under the transform folder. The file name must have the .map extension.

This file should be in property syntax, i.e. simple lines with "key=value" pairs. The file format is documented here. To organize the various transformations one might use subfolders.

A default value can be provided if no matching entry is found by using "=value" syntax

Example

transform/binary.map:

key=value
1=ON
0=OFF
ON=1
OFF=0
white\ space=using escape
=default
input output
1 ON
OFF 0
key value
white space using escape
anything default

Usage as a Profile

The functionality of this TransformationService can be used in a Profile on an ItemChannelLink too. To do so, it can be configured in the .items file as follows:

String <itemName> { channel="<channelUID>"[profile="transform:MAP", function="<filename>", sourceFormat="<valueFormat>"]}

The mapping filename (within the transform folder) has to be set in the function parameter. The parameter sourceFormat is optional and can be used to format the input value before the transformation, i.e. %.3f. If omitted the default is %s, so the input value will be put into the transformation without any format changes.

Please note: This profile is a one-way transformation, i.e. only values from a device towards the item are changed, the other direction is left untouched.