Transformation
Overview
The transform allows to change a value before publishing it or using in a callback.
The Expression language is used to define the transformation.
Some usage examples of transformations:
Converts a temperature from °F to °C
div(mul(sub(value, 32), 5), 9)
Changes a state base on a threshold
cond(gte(value, 10), true, false)
Perform OR operation on two reading (
root.value.reading_1androot.value.reading_2must be declared inaccessedValues)cond(or(asBoolean(root.value.reading_1), asBoolean(root.value.reading_2)), 1, 0)
Types
A value is automatically boxed into the internal value.ospp representation. For example, a boolean may be converted to the textual value “true” when the target value type is TEXT.
When a pre-transformation or post-transformation is applied, an additional configuration parameter can be defined to force the input type, preventing this automatic boxing behavior.
A typical case occurs when a textual input is converted to TEXT using a transformation rule.
The conversion process is then as follows:
Input type: TEXT — “error”
Pre-transformation: BOOLEAN — false
Usage
On Value
Pre transform
A pre-transformation can be configured on a value to convert it before it is being propagated further. To change the type of the value, the field transformType is mandatory.
Warning
This feature is not supported by all modules see modules capabilities for modules support
Note
If the type of a value is modified, the following pulse must use the same type for it’s reset value.
Post transform
A post-transformation can be configured on a value so that the value is converted before being transmitted. To change the type of the value, the field transformType is mandatory.
Warning
This feature is not supported by all modules see modules capabilities for modules support
Note
If the type of the value is modified, it must be the same as the final type of the value.
On Callback
A transformation can be configured on a transform callback to change the value sent to the targeted Output.