Skip to main content

Example

We receive a message and need to rename fields, calculate new values, and remove unused fields for cleaner downstream processing.

Input message

{
"furnace": {
"temp_c": 30.5,
"humidity": 64,
"pressure": 80
},
"site": "A1"
}

Target transformation

  • Move furnace.temp_c to furnace.temperature.celsius
  • Add furnace.temperature.fahrenheit (converted from Celsius)
  • Remove pressure
  • Change the site from A1 to B1

Output message (example)

{
"furnace":{
"humidity":64,
"temperature":{
"celcius":30.5,
"fahrenheit":86.9
}
},
"site":"B1"
}

What Node to be Used?

In this case, we use the change node to perform operations like Set, Change, Delete and Move on message properties.

ParameterDescription
Rules

Each rule is executed in order, top to bottom.
Multiple rules can be added to perform complex transformations.

Rule Type

Set: Set or create a property value.
Change: Find and replace.
Delete: Remove a property.
Move: Move a property from one path to another.

Property/Source/Target

Defines which property to operate on, such as msg.payload or msg.payload.furnace.temp_c.
Can also reference flow. or global. context variables.

Target Value

Set: The value to assign. • Change: The value to find and replace.

How to Use the Change Node?

  1. In EventFlow, drag in an inject node, and add the following json as the input.
{
"furnace": {
"temp_c": 30.5,
"humidity": 64,
"pressure": 80
},
"site": "A1"
}
  1. Connect it to a change node.
  2. Open the change node configuration panel and add rules.
  • Move msg.payload.furnace.temp_c → msg.payload.furnace.temperature.celcius
  • Set msg.payload.furnace.temperature.fahrenheit → payload.furnace.temperature.celcius * 9/5 + 32
  • Delete msg.payload.pressure
  • Change value of msg.payload.site from A1 → B1
  1. Connect the change node to a debug node to check the transformed output.