# Flow Enable/Disable Via Dashboard Control

**URL:** <https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670>\
**Category:** General\
**Created:** [29 September 2021 11:34 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670 "2021-09-29T11:34:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [29 September 2021 11:34 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670/1 "2021-09-29T11:34:49Z")

</div>

Good day O' Learned Ones!!

I have a situation where I need to switch a mode of control and data sampling between 2 methods under "emergency" situations....

I have 2 flows - Currently I enable one, disable the other, then deploy... This switches the methods and allows investigation/debug/corrections etc on the other, the 2 flows cannot "co-habit" simultaneously.

Is there a method, from within NR itself, to automate this via a dashboard?

Regds  
Ed

---

<div class="post-metadata">

**Author:** ![Mrb32](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mrb32](https://discourse.nodered.org/u/Mrb32)\
**Post date:** [29 September 2021 11:51 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670/2 "2021-09-29T11:51:30Z")

</div>

Assuming the same source is used for both flows, it sounds like a job for a switch node placed between the data input and the flows.

you could set-up a dashboard button to produce a true false value,  
The switch node would divert the data flow depending on this value, so if value = true, the data is passed on to flow 1, if it is false to flow 2.

If you are using different graphs/tables for both flows to display data on the dashboard, you could also use ui-control to show or hide the relevant groups depending on the status.

The flows could then co exist, as only one would handle data at any time.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [29 September 2021 12:07 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670/3 "2021-09-29T12:07:12Z")

</div>

I'm afraid that's not going to work for me, there are in the region of 50 data in / 50 out points on each flow, these are sent to other flows for processing, some processed on the spot, some of which are sent externally for recording... Way too complex to add alternate paths with switch nodes to every source/target....

---

<div class="post-metadata">

**Author:** ![Mrb32](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mrb32](https://discourse.nodered.org/u/Mrb32)\
**Post date:** [29 September 2021 12:08 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670/4 "2021-09-29T12:08:30Z")

</div>

I understand your predicament 🙂 Good luck!

---

<div class="post-metadata">

**Author:** ![rko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rko/32/45807_2.png) [@rko](https://discourse.nodered.org/u/rko)\
**Post date:** [29 September 2021 15:12 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670/5 "2021-09-29T15:12:27Z")

</div>

By `dashboard` you mean the flow editor or an UI accessible to end users?

I did a quick test within the editor but it's not a "one-click-solution". You could edit your flow-file (invert the disable properties of your two flows/tabs), save the file and then restart the flow(s) (plus pressing F5 to get the current version the browser) 😶

Assuming that your two flows are at position 0 and 1 in the json:

```auto
[
    {
        "id": "738a7b23b17c223e",
        "type": "inject",
        "z": "8a896ddec2ead8be",
        "name": "toggle",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 90,
        "y": 80,
        "wires": [
            [
                "030f1b4157a589ee"
            ]
        ]
    },
    {
        "id": "030f1b4157a589ee",
        "type": "file in",
        "z": "8a896ddec2ead8be",
        "name": "",
        "filename": "yourflow.json",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 250,
        "y": 80,
        "wires": [
            [
                "b411c80dddf5e107"
            ]
        ]
    },
    {
        "id": "daec30f7e9113f1b",
        "type": "function",
        "z": "8a896ddec2ead8be",
        "name": "",
        "func": "\n\n// dirty\nmsg.payload[0].disabled = !msg.payload[0].disabled;\nmsg.payload[1].disabled = !msg.payload[1].disabled;\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 80,
        "wires": [
            [
                "3b3f81aee4e7dbed"
            ]
        ]
    },
    {
        "id": "b411c80dddf5e107",
        "type": "json",
        "z": "8a896ddec2ead8be",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 410,
        "y": 80,
        "wires": [
            [
                "daec30f7e9113f1b"
            ]
        ]
    },
    {
        "id": "54c855e9665cefe6",
        "type": "file",
        "z": "8a896ddec2ead8be",
        "name": "",
        "filename": "yourflow.json",
        "appendNewline": true,
        "createDir": false,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 830,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "3b3f81aee4e7dbed",
        "type": "json",
        "z": "8a896ddec2ead8be",
        "name": "",
        "property": "payload",
        "action": "str",
        "pretty": false,
        "x": 690,
        "y": 80,
        "wires": [
            [
                "54c855e9665cefe6"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![rko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rko/32/45807_2.png) [@rko](https://discourse.nodered.org/u/rko)\
**Post date:** [29 September 2021 15:19 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670/6 "2021-09-29T15:19:46Z")

</div>

Sorry, I think this doesn't work. The restart does not really trigger a `startup`, so you might have to restart Node-RED through an `exec` node or something.

---

<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:** [28 November 2021 15:19 UTC](https://discourse.nodered.org/t/flow-enable-disable-via-dashboard-control/51670/7 "2021-11-28T15:19:58Z")

</div>

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