I use the config node node-red-contrib-config
to declare global variables like so:
And in function
node I get the value of the global aaa variable by global.get('aaa')
[{"id":"d1a34c16.5a144","type":"config","z":"aa40b590.ff1888","name":"","properties":[{"p":"aaa","pt":"global","to":"AAA","tot":"str"}],"active":true,"x":1740,"y":3020,"wires":[]},{"id":"f6f15e86.bd382","type":"function","z":"aa40b590.ff1888","name":"","func":"var value = global.get('aaa');\nmsg.payload = value;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":3080,"wires":[["53fe2cd9.4d1274"]]},{"id":"977a972b.ea5e18","type":"inject","z":"aa40b590.ff1888","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1590,"y":3080,"wires":[["f6f15e86.bd382"]]},{"id":"53fe2cd9.4d1274","type":"debug","z":"aa40b590.ff1888","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1910,"y":3080,"wires":[]}]
The problem I am having is:
in case there are multiple function
nodes using the same global aaa variable, and get the value by global.get('aaa')
as above,
then if I change the variable name aaa in config
node (suppose to become bbb) then I have to go to all function
nodes to change the variable name aaa of global.get('aaa')
to global.get('bbb')
This is inconvenient, is there any way I can use a global variable that when changing the variable name, I only need to change the variable name once?