How to STOP flows interactions

i have two counters in two different flows, somehow when i stopped the first counter and start the other it started where the first stops , it doesnt start from zero, how to fix this? thx in advance

You will have to share more details if you want help I'm afraid.

We have no idea what is in your flows, what nodes you are using etc.

If I were a gambling man, I would guess you are using the same global context variable in both "counters"?

Or perhaps you are using a contrib counter node? If so then tell us which one you have installed.

i m using a counter FUNCTION with this code below..with a start and stop buttons and a digital display..i copy pasted the flow the group flow is changed to test1 and test2

var counter = flow.get("counter") || 0
counter ++
flow.set("counter", counter)
msg.payload = counter
return msg;

  1. Changed what - the function name?

  2. How do you reset this?

  3. Are both functions on the same TAB

test1 and test2 are the two dashboard group nodes, below each group nodes we have two buttons one function and one digital display

1 -function name stayed the same
2-i m working to add a rest option if you can help :slight_smile:
3- i m not sure if both functions are on the same tab i dont know where check it

glad for you help

By function then I presume you are talking about Function nodes. In the editor where you can see the function node then you are looking at a tab. Is the other function node also visible in that tab or is it in a different tab in the editor?

same tab :sweat_smile:

Then that is your problem.

flow context is shared across all nodes in 1 tab.

1 Like

That is the problem then. Flow context applies to a tab in the editor. If you wish to use the same flow context variable name then you must put the other function node in a different tab. Or use node context if if the counter context variable is not needed outside the function.

1 Like

its working you saved my day :grin:

thx its working :grin:

You can avoid the problem by using the node context rather than flow context, as node context is specific to each node instance.
You said you needed a reset option. You could do that by defining that if msg.topic is "Reset" then reset the counter. Then (using node context) you might end up with something like this (untested):

let counter = context.get("counter") || 0
if (msg.topic === "Reset") {
  // reset the counter
  counter = 0
} else {
context.set("counter", counter)
msg.payload = counter
return msg;

:grin: thanks MrColin

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