Switching between two analogue values (manual/automatic) with a dashboard switch

Hi dear forum, I would like to switch between two analogue values (one that has been calculatet and one that is constant) from the dashboard using a switch node. The sense of it is to switch the output of a controller from manual to automatic mode. In manual mode it should use a value that can be edited in the dashboard and in automatic mode it should take the value calculated by the controller.

If I think about that problem, I allways end up with some node with three input (analogue1, analogue2, binary1) knowing that this can not be the way in node red. Stuck here!

The switch itself should also be switchcable via a time value. That means, automatic mode is active from 8:00 to 22:00 and manual mode from 22:00 to 8:00 (but thats just aditionally). Thanks in advance.

Have a look at the Join node, for joining your inputs into one message. See this article in the cookbook for an example of how to join messages into one object.

Hi, I tried the following


( could you explain how to post a snippet?) But thats not what I would like to have. It's more like open a path in one direction when binary1 is true and in the other if false. Every message comming in then should be propageted to either one or the other direction. Not waiting fpr three messages. Sorry, I'm still thinking in stereotypes!

Select the nodes and Ctrl-E (or Export via menu). When pasting use the </> button at the top of the forum entry window. See this post for more details - How to share code or flow json

The Join node does not need to wait for three messages every time. You can select 'and on subsequent messages' and then it will send the combined message every time any one comes in.
Once you have them in one message you can use a Switch node to only pass on the message when the topic matches the analogue topic, and then another to split the path dependent on the value of the binary.

[Edit] Actually you probably don't want the first Switch, as you need to change the output if the binary value changes.

Hi, that works as desired. How do I parse the object in the Switch node. Can I reference them by name? msg.payload.binary1 or msg.payload[1] ?

[
    {
        "id": "7c22c4349ab21472",
        "type": "inject",
        "z": "5331bb12.a5ac24",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "analogue1",
        "payload": "40",
        "payloadType": "num",
        "x": 290,
        "y": 680,
        "wires": [
            [
                "d7992a39a5c3ecc4"
            ]
        ]
    },
    {
        "id": "937abd8b8c0bf4fc",
        "type": "inject",
        "z": "5331bb12.a5ac24",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "analogue2",
        "payload": "50",
        "payloadType": "num",
        "x": 290,
        "y": 740,
        "wires": [
            [
                "d7992a39a5c3ecc4"
            ]
        ]
    },
    {
        "id": "d07f274009064d7a",
        "type": "inject",
        "z": "5331bb12.a5ac24",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "binary1",
        "payload": "true",
        "payloadType": "bool",
        "x": 290,
        "y": 800,
        "wires": [
            [
                "d7992a39a5c3ecc4"
            ]
        ]
    },
    {
        "id": "d7992a39a5c3ecc4",
        "type": "join",
        "z": "5331bb12.a5ac24",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": true,
        "timeout": "",
        "count": "3",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "num",
        "reduceFixup": "",
        "x": 550,
        "y": 780,
        "wires": [
            [
                "1921a5adfb412e87"
            ]
        ]
    },
    {
        "id": "d12954e001aba47d",
        "type": "debug",
        "z": "5331bb12.a5ac24",
        "name": "analogue1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 890,
        "y": 760,
        "wires": []
    },
    {
        "id": "9b9d054e5e2cd861",
        "type": "inject",
        "z": "5331bb12.a5ac24",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "binary1",
        "payload": "false",
        "payloadType": "bool",
        "x": 290,
        "y": 860,
        "wires": [
            [
                "d7992a39a5c3ecc4"
            ]
        ]
    },
    {
        "id": "70bc33f6ee91c816",
        "type": "debug",
        "z": "5331bb12.a5ac24",
        "name": "analogue2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 890,
        "y": 820,
        "wires": []
    },
    {
        "id": "1921a5adfb412e87",
        "type": "switch",
        "z": "5331bb12.a5ac24",
        "name": "",
        "property": "payload[3]",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "false",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 690,
        "y": 780,
        "wires": [
            [
                "d12954e001aba47d"
            ],
            [
                "70bc33f6ee91c816"
            ]
        ]
    }
]

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

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