Transfer a change from one node to all the same nodes

I wanted to ask if it is possible to change several nodes at the same time. As an example, I have several switch or range nodes in my flow for which I would like to change the entered values. I change the value of one node and this value is transferred to all other nodes in the flow. Something like a global variable, is there something in Node-Red?

Greetings Volker

like this?


i don't understand it yet. can you give me more information?


You can store a value in a global variable (called context) and re-use it as many times as you like - just like you asked.

Here is even more info


Thank you for your answer. I finally found time to test this time and managed to do it with the change and function Node. Now I wanted to ask whether it is possible to define the range node as a global variable. In my flow, the message payload runs repeatedly through an A / D converter node and then through the change node. There are a total of 16 change nodes in the flow and it is tedious to change the values ​​for all of them one after the other.

So my question again is it possible to change the values ​​of a change node and these are transferred to all others?

Here is a screenshot of my change node

Thank you for your efforts

Greetings Volker

It is trivial to implement a Range node using a function node, in the function you could send it a message to change the range, or use flow/global context to define the range.

you cant use flow or global variables for these but you can use environment variables


So we understand better, why do you have to change the ranges routinely.

do you have an example for this which explains exactly how it works? do you need an inject node for this?

I don't understand.

Only you know how you want to use the scale node.

Your picture where you drew red circles around the boxes - I demonstrated that while you cannot use global variables, you can use environment variables.

Do you know what environment variables are and how to use them?

no, unfortunately I don't know.

even from the node-red documentation, I do not judge really smart ...

how can I define the environment variables and retrieve them again?

So environment variables are set in your operating system before you launch node red.

For example, on Windows you might have a batch file that launches node-red. You can set up some variables before you launch node-red (like constants) that you can pick up in node-red

E.g., your batch file might be something like...

set f1=0
set t1=4095
set f2=1
set t2=100

Then when node-red is running, you can pick up the value of these & use them in the range node (and other nodes)

If you use Linux, then it would be export f1=0 etc.

I got it done.
with your advice and this page it worked.

1 Like

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