Count Messages - Reset externally

@Steve-Mcl

Hi, is there a way to reset the function code externally, for example, by clicking inject 0, the count should reset

If you mean can you put a button on a node-red dashboard to do the reset, the answer is YES.

If you mean a physical button, the answer is still YES, you just need to connect it up with the right hardware and use the correct node to read the incoming data.

Sorry for not being clear. i want to understand the changes i have to do in function code to read the 'reset' command, here in the example by pressing the inject node with a ' 0 '

Add a new inject node setting msg.payload to 'reset' then add some code to the start of the function node to

  1. test msg.payload for 'reset' - if true
  2. store 0 in the context variable
  3. maybe use node.status to display a msg undetr the node
  4. do a 'return;' to exit the function and not send anything down the wire.

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