I absolutely love NodeRed and use it for all automation-tasks in HA.There is however one functionality / node that I dearly miss:
Something similar to the switch node, where I can specify multiple conditions that each create an output. But instead of routing the message depending on the content of the message itself, It should be routed depending on the state of another entity.
I’m unsure wether I’m too stupid to see the obvious solution to this or if NR really has no possibility to do this - in my eyes - basic and absolutely crutial operation!?
Example:
Message arrives at one single input.
Condition-entity is a sensor for outdoor temperature in °C
IF state of condition-entity smaller or equal 0 THEN route message to output 1
IF state of condition-entity between 0 and 10 THEN route message to output 2
IF state of condition-entity betwenn 10 and 20 THEN route message to output 3
IF state of condition-entity bigger or equal 20 THEN route message to output 4
Seems simple enought, but I have not fund any way to do this!
I have thus far tried these approaches:
-
One could join the original message to be routed with the message of the state of the condition-entity to route them through a switch node, but that would mean externally querying the state of the condition each time and then joining and later un-joining it. Depending of the structures of the two messages this can get really complicated and each flow would be a one-off design.
-
It is kind of possible to do this with gate nodes that open and close whenever the state of the condition-entity changes. But this approach always depends on the last reported value, it does not ask for the current one. So when e.g. NR restarts or when redeploying, this breaks the flow. And if you want to have more that two conditions this increases the complexity exponentially since you need to build a cascade of gates and controls. More than 3 conditions is basically undoable.
-
One can operate a state machine that switches to a specific output depending on the state-change of the condition-entity. This works, but again depends on the latest reportetd value instead of the current one. One could mitigate this by querying the state of the condition-entity e.g. every second, but it creates uneeded system load and is just ugly.
Any input is very welcome. Thank you all in advance!