Switch using 'matches regex" - help needed

Hi

I have a payload coming in that is a variation of the following, which changes based on the input and outputs being used - below shows output 1 is using input 4

image

<@WVSO[1]I[4]

I want to use the switch node to take the flow down a different path depending on the payload received, and not being the best an regex, I went to this site (https://www.regex-generator.com/) to get the generic' expression for the above which it seems is as follows

(\x{3C}(([\w\.\-]*)\@([\w\.\-]+))\[(\d+)\](\w+)\[(\d+)\])

To help test it, I created two options within the switch node, one with the above string and another with rubbish text which I wanted to fail so I could see how the switch node worked, but for some reason I cant get it to work?

As this is to be used with a matrix device, I want to have each input output combination to take a different route. input 1 - output 1 go one way ; input 3 - output 2 go a different way.

image

I wonder if you will end up with a huge number of outputs in the switch node.

If it is for instance 4 inputs x 4 outputs then you will have 16 routes which is reasonable and could be (eventually) added individually in the switch node.

But what if this number is 10 x 10 ? Do you want to have 100 routes in the node ?

Another question. When the combination is input 1 , output 1 the incoming payload will be O[1]I[1] orO[01]I[01] ?

Yeah, that’s what I was thinking :slight_smile:

And it’s an 8x8 matrix too :frowning:

... but I have no idea how else to do it - this was all I could think to do - plus I have a number of other commands to send so the list will get longer.

What do you need to do after splitting them up? There may be alternatives to sending them down different paths.

Hi @Colin

I was looking to split them so I can capture the confirmation and responses from the matrix to update a dashboard I’m building, which can then show me (at anytime) the status of all the input/outputs etc.

The example below was for my previous 4x4 matrix

Hi @Andrei

They would both be single digit, e.g. O[1]I[1] - O[1]I[2] - O[5]I[7]

Hard to say without knowing more but I think you need to look at what Angular can do for you. I would rearrange the data into either an array or an object so that you can use a loop in Angular to create the boxes.

This is what I do on my home dashboard - though I'm using uibuilder with VueJS rather than Dashboard/Angular - however, the principles are the same.

Interesting use case. For an 8 x 8 matrix, a naive approach would result in an extremely large flow. It would not be complex but too big. I can´t imagine a switch node with one output for each 64 + extra commands. Even cascading switches would result in a quite large flow.

Perhaps you could consider the approach from @TotallyInformation .. or a totally different approach instead :smile:

What if you send the incoming payload to all the UI nodes and have a simple switch node in front of the UI node. This switch node would be just a gate to allow the message to pass or block it. Something like:

c-02

and perhaps you could use subflows to group common nodes. EDIT: not really.. bad idea

Each switch node would be something like shown below. Of course a specific string to each node.

c-03

I am really looking forward to seeing alternative solutions. I can't imagine a solution that will be easy to understand and manage. Given the number of UI nodes, the flow will always be huge. I guess this should not be considered an issue (as I first thought)

While probably somewhat from left field - Bart's recent fun with heatmaps - https://flows.nodered.org/node/node-red-contrib-ui-heatmap may be one way to quickly visualise an 8x8 array

1 Like

Thanks all for your input/ideas so far.

I’m afraid I don’t know anything about Angular and as for that heat map link, that looks very cool, but it feels like expert level stuff, where as I’m still very much a novice to intermediate ! :dizzy_face:

As the payloads are only returned when a request is successful sent to the matrix ; it seems I will need to have something that allows me to select any one of the 64+ available commands ?

Thankfully I don’t have 8 TVs so I’m not going to make use of all 8 outputs, but even a 3x8 or a 4x8 is still quite a bit, plus all the information request options e.g IP address, port status, EDID options

As the matrix information requests are fixed values, is there something I could do using a pick-list of commands to send - present the human friendly names in a drop down list and have the actual ascii command send in the background ? As the responses will all be different I will have to work out how I process those, but at least the send commands might be easier to do?

Seriously, it will take you less time to learn the little bit of Angular that you need than to write out so many nodes. There are plenty of examples of how to do this kind of task. All you need is to know how to create a small template using the Dashboard template node with a repeat on it.

Some examples from my blog

@nodecentral, if you are trying to simplify, you might consider whether every possible connection between an input and an output can occur at the same time. If so, you do need 8 x 8 = 64 (or in general n x n) indicators in the dashboard. The flow suggested by @Andrei is probably the most efficient, since it is "balanced" (symmetrical) and will on average do the least computation. However, if as I suspect is more likely, each input will connect to only one output at a given time (and vice versa), you can get by with a far simpler dashboard, just showing which connections exist at the moment. The 4 x 4 case might look like this:

Instead of 16 indicators, you need only 4. The "inputs" group is redundant, but it makes it easier to find the information you want. Obviously, the saving increases as the number of connections grows, and the case of unequal numbers of inputs and outputs is easy to handle. Even if the connections are not exactly one-to-one between inputs and outputs, there may still be limitations you can exploit to simplify the flow and dashboard.