Run flow only if precondition is met?

I have created a flow that reminds me if windows are open for a longer period of time but I only want to get the reminder if the outside temperature is below a certain threshold. I have the temperature already in the flow via a mqtt and a function node but I am struggling with how to use the temperature value as an inhibitor for the rest of the flow.
How can I implement such a precondition check?

1 Like

With a switch node placed between the part where the temperature is obtained and the rest of the flow.
In the switch a simple test with the value of the temperature and the threshold.
Have a look at and eg. Route a message based on one of its properties : Node-RED where a good example is provided.

I try not to use flow or global context wherever practical, so my choice would be to use a node-red-contrib-simple-gate to allow or block the messages, using the temperature to control the gate.

Thanks for the suggestions! The node-red-contrib-simple-gate was exactly what I needed. I used the function node that already extracts the temperature from the MQTT JSON to also set the topic to "control" and payload to "open" or "close" based on the temperature value.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.