User global environment variables are new, since v3.1
What I want to know is if, for example, a flow global variable can be set based on a user global variable?
And if so, what is the grammar for doing so?
User global environment variables are new, since v3.1
What I want to know is if, for example, a flow global variable can be set based on a user global variable?
And if so, what is the grammar for doing so?
I am asking the question because:
"Because of the need to make JSONata fully asynchronous in the future,
we’ve changed how the env var evaluation is done -
their values are now all generated when the flows start and not re-evaluated again."
Hi, welcome to the forum.
Unfortunately your question is not making a whole lot of sense (to me).
Perhaps some annotated screenshots would help me understand what you are attempting to do (and perhaps there is a better way)
Sure,
Suppose you have set a bunch of user level global variables.
I also have some flow(tab) level global variables:
In the two images the variables are duplicated.
Is there a way to use the user level variables to provide values to the global variables defined in a config node in the flow(tab)?
I am probably not asking this very well and I do not fully understand what a global and flow(tab?) variable defined in a config node are and how that flow(tab) global variable differs (if at all) from one defined at the user level.
Something like:
Property : global. FTH_FTS_URL_MAP
Value : str. ${FTH_FTS_URL}
I currently have a node on each tab defining the same global variables.
I assumed the global variables were global to the specific tab.
Is that wrong?
I think I am wrong.
After reading the documentation it seems like I will end up with indeterminate behaviour.
Would the following syntax work?
Property : flow. FTH_FTS_URL_MAP
Value : str. ${FTH_FTS_URL}
What node is ↑ this?
you can use ENV VARs in most fields using ${ENV_VAR_NAME}
but they are not re-writtable is thats what you are asking?
you can also use a change node to SET global.something
to the value of env.something
Some clarification:
ENV VARs are fixed. Cannot be changed at runtime, ENV VARS can come from the OS or configured in Node-RED
Global and Flow are context and can be read/write and any time, at runtime.
Here is some reading and watching that should help:
I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.
The node "Edit config node" is this one, a config node:
I will watch the videos and read the link you sent.
that is NOT a node-red node. It is a contib / add in node. thats partly why i was confused by your questions.
Typically, if you want to use an ENV VAR, you select Env
from the drop down OR, if its got an Env
dropdown, you use $(ENV_VAR_NAME)
This node (whatever it is) was likely added to simplify either Env or Context but unless i know which one it is, i have no idea if it is talking about context, env vars or some other made up type of variable storage.
I have been able to programmatically load flows in ansible with:
uri:
url: "http://{{ noderedserver_ipv4 }}:{{ noderedserver_port }}/flow"
method: POST
headers:
Content-Type: application/json
Node-RED-API-Version: v1
Node-RED-Deployment-Type: full
Authorization: Bearer {{ nodered_admin_token }}
body: "{{ lookup('file', playbook_dir + '/FreeTAKHub-Webmap/freetakhub_config.json') }}"
body_format: json
status_code: 200
This simulates the the "Import" function.
What is the recommended way to initialize the global variables?
Possibly the reload option? (for memory based context)
Failing that, include a flow with a callable endpoint
http-in -> function (iterate and reset context) -> http-response
Could they be set in https://nodered.org/docs/user-guide/runtime/settings-file
before starting node-red?
...
exportGlobalContextKeys: true,
...
functionGlobalContext: {
FTH_FTS_URL = "127.0.0.1",
FTH_FTS_TCP_Port = "8087"
},
...
no. settings are loaded first (before context)
You may need to create a plugin node or go with the flows option.
PS, did you try the reload?
This suggests I can overwrite the global flow:
Put Flow Node : Global
However when I look at the exported flow, I do not see a node with "global" id.
What is see is the following:
{
"id": "3f81c31d1e0b6231",
"type": "global-config",
"name": "global-config",
"env": [
{
"name": "FTH_FTS_URL",
"value": "127.0.0.1",
"type": "str"
},
{
"name": "FTH_FTS_TCP_Port",
"value": "8087",
"type": "str"
}
]
}
In terms of flows, "global" is refering to global things like context nodes.
To clarify - what are you actually trying to do? Are you attempting to reset global context? Global environment variables? Global flows nodes?
Global environment variables.
(In case it was not obvious, I inherited this project and am just learning NodeRed.)
Which ones? Those set in the main menu or those set by the launching environment? Those set in flow tab? Those set in a subflow? All of them?
Also, are 100% certain you mean environment variables and not global content?
Perhaps a little learning would clarify matters.
I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.
Yes I watched all the videos (when you mentioned this before).
I am going through them again working all the examples.
I probably mean "global context".
But when the dialog is clearly labeled "Global Environment Variables" it makes one think that they are global environment variables:
Ok, so I'm pretty sure those particular values are stored in the flow JSON. If you want to clear them you would need to manipulate the JSON before issuing the POST to /flows
They are environment variables. The cannot be modified at run time.