Switch


The Switch node branches the flow to different nodes according to the configured case values, which are represented by their corresponding lables.

Node Type

Logic.

Input and Output Ability

This node has 1 entry point and multiple exit points. Both the input and output are JSON. The Swich node has a default label “Others”, which the flow will follow if the input does not satisfy any of the exit branches that have a specific label. For more information on labels, refer to the Node Properties section.


As this node does not modify the input message, the output will be the same as the input.

Note

You need to configure one exit point using the “Others” label.

Node Properties

../../_images/switch.png


Node Name

Required.

The name for this node.


Case

Required.

Cases are the conditions that you specify for the node to branch the flow to, with each case representing one branch. Use expressions to specify the condition, and enter a corresponding label for the case.

  • Condition

    The values for the conditions support only numbers and strings, for example ${msg.key}>=7 and ${metadata.topic}='yourTopic', with numbers supporting >, <, >=, <=, =, <>, and != operators and strings supporting <> and = operators.

  • Label

    When dragging connectors from the exit point of the Switch node to the entry point of the next node, you need to select the label that represents the condition for the flow to branch to, and the connector will have the label name attached to it. Each lable can only be used once, i.e., each condition can only be used for a single branch.


    The Swich node has a default label “Others”, which the flow will follow if the input does not satisfy any of the exit branches that have a specific label.


If there are multiple cases, when the flow runs, the order of evaluation is from top to bottom. For example, if an input message satisfies multiple case conditions, the topmost case that matches the condition will be the branch that is followed by the flow.


If the input message does not satisfy any case condition, the flow will follow the branch with the “Others” label.


Description

Optional.

The description for this node.

Limitations

  • Maximum number of cases: 5

Samples

Input Sample

{
    "externalId":"Inverter",
    "timestamp":24214324324,
    "measurepoints":{
        "speed":32,
        "heat":40
    }
}

Output Sample

The output message will be the same as the input message.

{
    "externalId":"Inverter",
    "timestamp":24214324324,
    "measurepoints":{
        "speed":32,
        "heat":40
    }
}