Flow Enable/Disable Via Dashboard Control

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

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.

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....

I understand your predicament :slight_smile: Good luck!

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) :no_mouth:

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

[
    {
        "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"
            ]
        ]
    }
]

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.