Hi,
i am new on NR and building up the first flows. Every thing is working, but some points can be made better, I think.
One question to start. I have an switch node to select the outputs based on the topics. For now I have 6 outputs, but would like to have the 3+4 and 5+6 on the same output. And its not enough to have an filter only on the part "cool_" or "heat_", this will match with to much topic.
Is this a point to use Jsonata?
I think a regular expression test would do it, as you can match on cool_ followed by target or diff. I am not going to tell you how to do it though, as I don't use regex much and would have to look it up and then play with it till it worked. So I will leave that for you to do yourself
Actually, if you order them correctly, which you already have, and select that it stops on the first match (the drop down at the bottom), then you just need to check for Contains heat_ and Contains cool_ as the other options will already have been ruled out. Unless there are other matching strings that you want to ignore completely that is.
As @Colin said, regex is your "friend". Kind of... as it is not the friendliest stuff to use.
However if you want to send 3 and 4 to the same output, you can do:
Stop at first match means that it tests the first condition, if that is satisfied then it sends the message to output 1 and does nothing else. If the first test does not match then it tries the second test, and if that matches it sends the message to output 2 and does nothing else, and so on for each test. So in your original configuration if you selected this option then if it gets as far as test 5 then you would know that it was not cool_switch_state so need only test for Contains cool_ to identify both cool_target and cool_diff.
If you select Check all rules then it tests all the rules every time and will send the message to all outputs that match, not just the first one, which is obviously a waste of time in your original configuration as only one can match each time.
I understand. But There are more topics not shown in my first post also starting with cool_ or heat_ to implement later. So I have to take care on the order in this switch.
But vor now its right to use the first match only.
OK, in that case the regex method may be safer and easier to follow when you come back to look at it in a years time
Though still it should be first match as that saves it wasting time when a match has been found.
I think first match would be better as the default, but that is another matter.