# Copying environment variables

**URL:** <https://discourse.nodered.org/t/copying-environment-variables/82255>\
**Category:** General\
**Tags:** home-assistant\
**Created:** [22 October 2023 12:51 UTC](https://discourse.nodered.org/t/copying-environment-variables/82255 "2023-10-22T12:51:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevegroom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevegroom/32/19591_2.png) [@stevegroom](https://discourse.nodered.org/u/stevegroom)\
**Post date:** [22 October 2023 12:51 UTC](https://discourse.nodered.org/t/copying-environment-variables/82255/1 "2023-10-22T12:51:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 October 2023 13:00 UTC](https://discourse.nodered.org/t/copying-environment-variables/82255/2 "2023-10-22T13:00:58Z")

</div>

@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

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

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 October 2023 13:35 UTC](https://discourse.nodered.org/t/copying-environment-variables/82255/3 "2023-10-22T13:35:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stevegroom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevegroom/32/19591_2.png) [@stevegroom](https://discourse.nodered.org/u/stevegroom)\
**Post date:** [23 October 2023 14:29 UTC](https://discourse.nodered.org/t/copying-environment-variables/82255/4 "2023-10-23T14:29:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [25 October 2023 12:29 UTC](https://discourse.nodered.org/t/copying-environment-variables/82255/5 "2023-10-25T12:29:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 December 2023 12:30 UTC](https://discourse.nodered.org/t/copying-environment-variables/82255/6 "2023-12-24T12:30:37Z")

</div>

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