Stop reading sensor function

hi, i'm trying to make a button or a switch to stop reading a sensor so basically is to stop the payload from the mqtt in node to a function or make a funcion to stop reading values after 10 seconds

Wire a button/switch to a change node to set flow context, then behind the mqtt in a switch to see if the flow context allows passing through and if not just drop the message/stop the flow?


...or you could use node-red-contrib-simple-gate which would act as a gate that you can open or close.


The alternative I had in mind but didn’t suggest yet :wink:

what is your solution?

i think it works i will keep using it to see the results thanks

thanks @Paul-Reed both solutions were really good ones

The advantage of the gate node is that you can feed the switch directly into it without the need for context variables.

1 Like