Switch


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

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 Switch node has a default label “Others”, which the route 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


Name

The name for this node.


Case

Cases are the conditions that you specify for the node to branch the message 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. The key of metadata is not case sensitive, and the value needs to be case sensitive.

  • 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 label 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 route 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 rule 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 rule.


Description

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
    }
}