How to filter or route variables

How to filter or route a variable?

1. When is it useful to filter variables?

In some cases it is useful to filter some variables. For instance, when you perform post-processing you may want to plot only the post-processed variable and not the original one. This article provides some solutions to:

  • hide useless variables
  • plot some variables on different charts
  • plot only the post-processed variable, and not the original one.

The following sections present two ways to perform this routing or filtering:

  • create 2 groups of variables
  • use switch nodes.

2. First solution: Create two groups of variables

You can create two different groups of variables (variable nodes), and consequently the same number of processing nodes. One can be connected to the gauge and the other to the chart.

Flow with 2 Groups of variables.png

3. Second solution: use switch node

3.1. Basic switch node configuration

You can use the “switch node” in a similar way to a filtering node (which lets a variable pass) on the output of the processing node. The switch node filters your variable on the following property: msg.payload.variablename and myVariableName.

Flow with switch node.png

Switch node configuration:

  • Name - choose a name for your node
  • Property - msg.payload.variablename is the condition to select a variable. Here you are going to select the needed variable by using its variable name.
  • Condition - == yourVariableName if you want to filter only one variable. You can use other rules such as != yourVariableName to filter all variables except one variable.

Here is an example of a "switch node" configuration panel:

Switch node configuration.png
Warning white.png Warning
Be careful, the variable name has to be exactly the same as that in the processing node (without space before and after). You can copy/paste it from the processing node

You can either use several serial or parallel “switch nodes” to filter multiple variables:

3.2. Serial switch nodes

If you want to block some variables you can use serial "switch nodes" with the != condition.

Switch Node Series.png

In this example, the first "switch node" is used to block the average temperature variable, and the second "switch node" to block the voltage variable. Thus, these two variables are not plotted on the graph.

3.3. Parallel switch nodes

If you want to select specific variables you can use "switch nodes" in parallel with the == condition.

Switch Node Parallels.png

In the previous flow, the temperature and voltage variables are each routed by a switch node. The two switch nodes are in parallel. Thus you can either plot the two variables in the same, or in different, graphs.

3.4. Switch nodes with several conditions

To block several variables you can use a single "switch node" with multiple outputs. You need to add several conditions. For instance, to plot all variables except the temperature and the voltage, we need 3 conditions:

  • two "==" conditions
  • one "otherwise" condition

Let's take a look at the following conditions configuration:

Switch node (multiple conditions).png

In order to suppress the temperature and voltage variables on your graph, plot the "otherwise" condition; that is, output 3 (see the following picture).

Unique switch node.png

Conversely, if you want to allow the temperature and the voltage to pass, and not the other variables, you have to plot the outputs 1 and 2 to your graph, as in the following picture. You no longer need the "otherwise" condition.

Switch node (pass filter).png