Just to make it clear: this is NO feature request.
It is only an idea about an existing Trello item (switch-add-compound-rules):
Today at work I had to create a compound filter in the Zabbix user interface.
Zabbix allows following options on the screen to combine multiple filters:
So Zabbix allows this:
Use AND for all filters
Use OR for all filters
Use AND/OR which means it will use and for the first N filters and OR for the last filter. For example -"(A AND B AND C) OR D". But I'm not sure if anybody uses that option, because the next option is much more flexible.
Use "Custom expression" to enter a free-text expression like this:
This works fine and it is very flexible. Only disadvantage is that Zabbix doesn't validate the expression in a user-friendly way.
When I saw this Zabbix screen, I immediately thought about the Switch node ...
A Switch node with an editableList on top containing all the current typedInput's, and another editableList containing expressions and the corresponding output numbers ...
Although most probably Nick and Dave had already something much better in mind already.
But I don't see a link to a design document in Trello, so I'm not sure.
Anyway, it is only an example how other software does something similar.
Nothing more nothing less ...
I really like this design. This would take away a lot of the times when one either needs several switch nodes in series or parallel or a function node. At least for me this would clean up a lot of my flows nicely. I can see that coming up with an intuitive way to integrate this into the current switch nodes up would be the hardest part.
My concern is that gets quite complicated quite quickly - especially for all existing flows that don't use compound rules. For those cases (again, 100% of existing cases) you have to add both the rule and the port mapping to go with it as two separate 'things' and hope you keep them in sync. I'm not sure that is very intuitive. To understand what port mapping is doing, you have to constantly refer between the two tables - you can't just 'read' it. This is as much a critique of Zabbix's approach as it is however it might translate into the Node-RED UI.
Before you go too far down this path, one of the main requirements of the compound rules feature is to be able to define rules that check against multiple properties of the message - msg.payload > 80 AND msg.topic === "temp" for example.
You can do that already, by hand coding the tests in jsonata. Possibly not as convenient as a GUI where more complex rules are required but very powerful.
Yes, you are absolutely right - but it does limit you to one rule per node (with only true/false outputs).
There are other tricks you could do you use JSONata to build a single value containing all the bits you want to test... but they are just that, tricks.
And the existing approach of having multiple tiers of Switch node can also be used.
The idea around compound rules is to make it all a bit more intuitive and self-contained.
Yes, I agree. I just wanted to point out that way of using the node which others may not have thought of.
Though I am not sure how often I would need more than that provided by basic switch node usage or using expression evaluation using JSONata.
Hey Steve,
I had seen that one also, but not used yet.
I'm going to work on the svg node next week, so don't expect a node-red-contrib-query-builder from me
my concern is that again, unless extremely clear, folk will presume this also works across two different messages (ie is capable of AND-ing two inputs)
I think the original thoughts around this were from back here - Redirecting to Google Groups
(which may give an alternative view)