Copying environment variables

Hello,
I started to use environment variables to store config relating to a flow, I then duplicated the flow and changed its environment variables to customise the flow for a different environment.

For example, I have 12 environment variables to defining elements used in the office flow in my home assistant setup. I'm reusing a lot of those elements in my bedroom and have to manually recreate all 12 environment variables in the new flow.

Is there a way to export / import the environment variables from one flow to another?

regards
Steve

@stevegroom

I have exported a flow that has EV's.
And I can re-import this flow along with it's EV's with no problem.

This might be a problem with Home Assistants version of Node RED - most here use Node RED bare-metal

[
    {
        "id": "40ea96e082085fa9",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": [
            {
                "name": "Hello",
                "value": "World",
                "type": "str"
            }
        ]
    }
]

It depends on where you created the env vars, how you export, what version of Node-RED etc.

In newer versions of Node-RED you can specify env vars in a group, export/import the group - job done. Also, if you add env vars in tab properties, if you export the tab, then import it, they should get imported.

1 Like

Thanks' for the replies.

I can copy a flow which includes the env variables set on its tab, but I cannot copy these env variables to another flow - only a new flow.

I tried the suggestion of creating a group with the env variables, but these are scoped to the group, so also not useful in this case.

I think I will create a single env variable that contains a json object containing all the constants I need to use. At least this can be manually copied in a single step.

1 Like

Or you can put all env vars on a single tab or single group and use link-call to grab them from your "setup" tab or group and put them into msg.payload for you.

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