Hi @hominidae,
Are you sure this applies to environment variables set through the subflow properties?
- In my case, one of the environment variables I pass is a light sensor name, and the lights turn on/off correctly. If the variables were shared, all instances would control the same light.
- That would defeat the purpose of configuring environment properties within the subflow—how would you track the actual values if each instance allows different settings?
Here’s a working example (interestingly, "DEBUG" behaves as expected in this case):
example:
[
{
"id": "c77464f0692082d8",
"type": "subflow",
"name": "envVariable",
"info": "",
"category": "",
"in": [
{
"x": 120,
"y": 60,
"wires": [
{
"id": "ae2c437f642028e2"
}
]
}
],
"out": [
{
"x": 380,
"y": 60,
"wires": [
{
"id": "ae2c437f642028e2",
"port": 0
}
]
}
],
"env": [
{
"name": "testName",
"type": "str",
"value": "test1"
},
{
"name": "DEBUG_VERBOSE",
"type": "bool",
"value": "false"
}
],
"meta": {},
"color": "#DDAA99"
},
{
"id": "ae2c437f642028e2",
"type": "function",
"z": "c77464f0692082d8",
"name": "test",
"func": "node.warn(env.get(\"testName\"));\nconst DEBUG = env.get(\"DEBUG_VERBOSE\");\nif (DEBUG) node.warn(\"DEBUG is TRUE\");\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 250,
"y": 60,
"wires": [
[]
]
},
{
"id": "4284f5b11bac1fb9",
"type": "tab",
"label": "test env variables",
"disabled": false,
"info": "",
"env": []
},
{
"id": "087aa76bd5d5b795",
"type": "subflow:c77464f0692082d8",
"z": "4284f5b11bac1fb9",
"name": "",
"x": 330,
"y": 80,
"wires": [
[]
]
},
{
"id": "3a284023c415c461",
"type": "inject",
"z": "4284f5b11bac1fb9",
"name": "all",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 90,
"y": 40,
"wires": [
[
"087aa76bd5d5b795",
"32cd43170e7b4147",
"9d12c18e69614587"
]
]
},
{
"id": "32cd43170e7b4147",
"type": "subflow:c77464f0692082d8",
"z": "4284f5b11bac1fb9",
"name": "",
"env": [
{
"name": "testName",
"value": "test2",
"type": "str"
},
{
"name": "DEBUG_VERBOSE",
"value": "true",
"type": "bool"
}
],
"x": 330,
"y": 140,
"wires": [
[]
]
},
{
"id": "9d12c18e69614587",
"type": "subflow:c77464f0692082d8",
"z": "4284f5b11bac1fb9",
"name": "",
"env": [
{
"name": "testName",
"value": "test3",
"type": "str"
}
],
"x": 330,
"y": 200,
"wires": [
[]
]
},
{
"id": "5bb8a70d185d4f03",
"type": "inject",
"z": "4284f5b11bac1fb9",
"name": "1",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 90,
"y": 80,
"wires": [
[
"087aa76bd5d5b795"
]
]
},
{
"id": "df967d6c47cead50",
"type": "inject",
"z": "4284f5b11bac1fb9",
"name": "2",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 90,
"y": 140,
"wires": [
[
"32cd43170e7b4147"
]
]
},
{
"id": "9e83536746611a40",
"type": "inject",
"z": "4284f5b11bac1fb9",
"name": "3",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 90,
"y": 200,
"wires": [
[
"9d12c18e69614587"
]
]
}
]