# Remote Update Single Tab of Flow

**URL:** https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758
**Category:** General
**Created:** [20 March 2023 15:09 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758 "2023-03-20T15:09:25Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2023 15:29 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/21 "2023-04-02T15:29:55Z")

</div>

> [@ChZeman](#):
>
> It would be OK if the ethip-in, pccc-in, and dde nodes allowed for passing all the parameters to them and runtime but they don't, so I need to leave the first tab alone.

Could you use environment variables in the individual machines, so the flows are the same on all devices?

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 16:00 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/22 "2023-04-02T16:00:47Z")

</div>

I thought so, but I must be missing something.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2023 16:29 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/23 "2023-04-02T16:29:33Z")

</div>

Post here a sample flow which just posts a flow with a single node for us to look at.

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 16:37 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/24 "2023-04-02T16:37:59Z")

</div>

I've been attempting to do this using curl with command line using the command (and variations thereof) that I posted before.

```auto
CYCLES=$(<Cycles.json)
curl -H "Authorization: Bearer ${TOKEN}" -X PUT http://${IP}:1880/flow/f72d85c5e090800f -d `"${CYCLES}"`

```

```auto
CYCLES=$(<Cycles.json)
curl -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -X PUT http://${IP}:1880/flow/f72d85c5e090800f -d `"${CYCLES}"`

```

```auto
curl -d "@Cycles.json" -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -X PUT http://${IP}:1880/flow/:f72d85c5e090800f

```

```auto
[
    {
        "id": "f72d85c5e090800f",
        "type": "tab",
        "label": "Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1841dfa69e5c3254",
        "type": "eth-ip in",
        "z": "f72d85c5e090800f",
        "endpoint": "96b408201848d104",
        "mode": "all",
        "variable": "",
        "program": "",
        "name": "",
        "x": 90,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "96b408201848d104",
        "type": "eth-ip endpoint",
        "address": "192.168.1.1",
        "slot": "0",
        "cycletime": "3000",
        "timeout": "10000",
        "name": "",
        "connectedMess": true,
        "vartable": {
            "": {
                "CYCLES_VEHICLE_1": {
                    "type": "DINT"
                },
                "CYCLES_VEHICLE_2": {
                    "type": "DINT"
                },
                "ERROR": {
                    "type": "DINT"
                },
                "STATUS": {
                    "type": "DINT"
                }
            }
        }
    }
]

```

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 16:47 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/26 "2023-04-02T16:47:09Z")

</div>

I just updated the post. I forgot to include a sample flow. 🙂

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2023 16:59 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/27 "2023-04-02T16:59:07Z")

</div>

See [Types : Node-RED](https://nodered.org/docs/api/admin/types#single-flow-configuration) for what you should be posting, I think.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [2 April 2023 16:59 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/28 "2023-04-02T16:59:53Z")

</div>

The payload format for updating an individual tab is different.

The API docs give an example of the format, but if in doubt, do a GET to the same URL to see the format.

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 17:07 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/29 "2023-04-02T17:07:47Z")

</div>

Doing a GET returns the content of the flow, the same content that is in my JSON export of the tab in NR. Isn't that what I'm supposed to be sending to NR?

```auto
curl -H "Authorization: Bearer ${TOKEN}" -X GET http://${IP}:1880/flow/f72d85c5e090800f

{"id":"f72d85c5e090800f","label":"Test","disabled":false,"info":"","env":[],"nodes":[{"id":"1841dfa69e5c3254","type":"eth-ip in","z":"f72d85c5e090800f","endpoint":"96b408201848d104","mode":"all","variable":"","program":"","name":"","x":90,"y":80,"wires":[[]]}]}

```

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [2 April 2023 17:40 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/30 "2023-04-02T17:40:00Z")

</div>

The format is different.

You are posting an array of nodes. The API expects a single object that is the `tab` object, that has a `nodes` property containing the array of nodes on the flow.

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 17:51 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/31 "2023-04-02T17:51:23Z")

</div>

If I'm understanding correctly, I can't simply export a tab and use that file as-is. I have to modify it to match a different format?

In other words, turn this:

```auto
[
    {
        "id": "f72d85c5e090800f",
        "type": "tab",
        "label": "Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1841dfa69e5c3254",
        "type": "eth-ip in",
        "z": "f72d85c5e090800f",
        "endpoint": "96b408201848d104",
        "mode": "all",
        "variable": "",
        "program": "",
        "name": "",
        "x": 90,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "96b408201848d104",
        "type": "eth-ip endpoint",
        "address": "192.168.1.1",
        "slot": "0",
        "cycletime": "3000",
        "timeout": "10000",
        "name": "",
        "connectedMess": true,
        "vartable": {
            "": {
                "CYCLES_VEHICLE_1": {
                    "type": "DINT"
                },
                "CYCLES_VEHICLE_2": {
                    "type": "DINT"
                },
                "ERROR": {
                    "type": "DINT"
                },
                "STATUS": {
                    "type": "DINT"
                }
            }
        }
    }
]

```

into this?

```auto
{
  "id": "f72d85c5e090800f",
  "label": "Test",
  "nodes": [{
        "id": "1841dfa69e5c3254",
        "type": "eth-ip in",
        "z": "f72d85c5e090800f",
        "endpoint": "96b408201848d104",
        "mode": "all",
        "variable": "",
        "program": "",
        "name": "",
        "x": 90,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "96b408201848d104",
        "type": "eth-ip endpoint",
        "address": "192.168.1.1",
        "slot": "0",
        "cycletime": "3000",
        "timeout": "10000",
        "name": "",
        "connectedMess": true,
        "vartable": {
            "": {
                "CYCLES_VEHICLE_1": {
                    "type": "DINT"
                },
                "CYCLES_VEHICLE_2": {
                    "type": "DINT"
                },
                "ERROR": {
                    "type": "DINT"
                },
                "STATUS": {
                    "type": "DINT"
                }
            }
        }
    }],
  "configs": []
}

```

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [2 April 2023 18:07 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/32 "2023-04-02T18:07:56Z")

</div>

Yes. As described in the docs, the `/flow` endpoint uses a slightly different format, but the translation between them is fairly straightforward.

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 18:14 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/33 "2023-04-02T18:14:16Z")

</div>

To be sure I understand...

I need to export that tab of my flow and then modify the file before trying to update it on the remote Pi using curl? I ask because NR didn't like that either. Then it hit me that I needed to set the parameters (id, label, nodes, configs) in curl so I did that...

```auto
TEST=$(<Test.json)

curl --header "Content-Type: application/json" --request POST --data '{"id":"f72d85c5e090800f","type":"tab","label":"Test","nodes":"${TEST}","configs":[],"subflows":[]}' -H "Authorization: Bearer ${TOKEN}" -X PUT http://${IP}:1880/flow/f72d85c5e090800f

```

...and was presented with a nice little red box in NR when I opened it.

```auto
Error adding flows

f.type is undefined

```

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [2 April 2023 18:35 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/34 "2023-04-02T18:35:37Z")

</div>

Without knowing what was in Test.json, it's hard to say what has happened.

Did you remove the `tab` node from the export before adding it in the `nodes` array?

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 18:46 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/35 "2023-04-02T18:46:21Z")

</div>

Test.json is what was downloaded from NR when I exported the tab. I tried it both as downloaded (when the edited version failed) and also the edited version you said I needed it changed to.

Original Test.json:

```auto
[
    {
        "id": "f72d85c5e090800f",
        "type": "tab",
        "label": "Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1841dfa69e5c3254",
        "type": "eth-ip in",
        "z": "f72d85c5e090800f",
        "endpoint": "96b408201848d104",
        "mode": "all",
        "variable": "",
        "program": "",
        "name": "",
        "x": 90,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "96b408201848d104",
        "type": "eth-ip endpoint",
        "address": "192.168.1.1",
        "slot": "0",
        "cycletime": "3000",
        "timeout": "10000",
        "name": "",
        "connectedMess": true,
        "vartable": {
            "": {
                "CYCLES_VEHICLE_1": {
                    "type": "DINT"
                },
                "CYCLES_VEHICLE_2": {
                    "type": "DINT"
                },
                "ERROR": {
                    "type": "DINT"
                },
                "STATUS": {
                    "type": "DINT"
                }
            }
        }
    }
]

```

Edited Test.json (also failed):

```auto
{
  "id": "f72d85c5e090800f",
  "label": "Test",
  "nodes": [{
        "id": "1841dfa69e5c3254",
        "type": "eth-ip in",
        "z": "f72d85c5e090800f",
        "endpoint": "96b408201848d104",
        "mode": "all",
        "variable": "",
        "program": "",
        "name": "",
        "x": 90,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "96b408201848d104",
        "type": "eth-ip endpoint",
        "address": "192.168.1.1",
        "slot": "0",
        "cycletime": "3000",
        "timeout": "10000",
        "name": "",
        "connectedMess": true,
        "vartable": {
            "": {
                "CYCLES_VEHICLE_1": {
                    "type": "DINT"
                },
                "CYCLES_VEHICLE_2": {
                    "type": "DINT"
                },
                "ERROR": {
                    "type": "DINT"
                },
                "STATUS": {
                    "type": "DINT"
                }
            }
        }
    }],
  "configs": []
}

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2023 19:23 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/36 "2023-04-02T19:23:49Z")

</div>

You have not responded to my suggestion that you use environment variables to configure the different machines, thereby removing the necessity for doing any of this.

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 19:28 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/37 "2023-04-02T19:28:27Z")

</div>

Rest assured I'm also looking into that. I'm trying to figure out how I would implement environment variables in node-red-contrib-cip-st-ethernet-ip, node-red-contrib-dde, node-red-contrib-pccc, and node-red-contrib-s7.

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 19:32 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/38 "2023-04-02T19:32:13Z")

</div>

If I used environment variables and just deployed the entire flow to deploy updates, wouldn't that delete my configuration nodes on the target?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [2 April 2023 20:06 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/39 "2023-04-02T20:06:38Z")

</div>

You would set the environment variables outside of Node-RED - unique to each device. So when Node-RED starts is reads the local environment and sets the required fields as appropriate. see [Using environment variables : Node-RED](https://nodered.org/docs/user-guide/environment-variables)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2023 20:49 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/40 "2023-04-02T20:49:31Z")

</div>

> [@ChZeman](#):
>
> wouldn't that delete my configuration nodes on the target?

No, as Dave said, in any node you can put `${ENV_VAR}` in the nodes config fields, and it will use whatever is in that environment variable.

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [2 April 2023 21:23 UTC](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758/41 "2023-04-02T21:23:44Z")

</div>

Very good and thank you. I did try that earlier and it works well for the endpoint configuration in an ethip-in node but it does not work for the tags I need to read. Even then, I won't be monitoring the same number of tags or addresses on each machine. That's why you'll see in the following screenshots I created "BLANK" with nothing there to see how the node would react to that. I was expecting it to read the first two tags fine and generate an error on the third.

Perhaps @ [machadotiago](https://discourse.nodered.org/u/machadotiago) can chime in on what to do there.

![MWSnap-ChZemanDesktop 2023-04-02, 16_08_04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70258b0d0711ac5469d0b541002b029804ac36da.png)

![MWSnap-ChZemanDesktop 2023-04-02, 16_13_05](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60997583d937127667394db5861b0121883cae9c.png)

 ![MWSnap-ChZemanDesktop 2023-04-02, 16_13_15](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e517f66a5f1930beb1ef7ad4df8a036825efa4f2.png)

As far as updating individual tabs, I give up. The documentation IS lacking on that front. Simple examples in documentation go a long way. If I wasn't able to figure it out by now it's not worth the effort and it sure looks like using environment variables is out the door, too.

I would really have preferred using environment variables but it doesn't appear ST-One's node's support them. I hope I'm wrong because I'm stuck doing updates the long way (about 50 pieces of equipment, more in the future) if they don't.

[Previous page](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758.md?page=1)

[Next page](https://discourse.nodered.org/t/remote-update-single-tab-of-flow/76758.md?page=3)
