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

**URL:** <https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184>\
**Category:** Dashboard\
**Tags:** function-node\
**Created:** [31 July 2023 10:30 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184 "2023-07-31T10:30:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Popolackie](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@Popolackie](https://discourse.nodered.org/u/Popolackie)\
**Post date:** [31 July 2023 10:30 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184/1 "2023-07-31T10:30:48Z")

</div>

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.

---

<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:** [31 July 2023 10:44 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184/2 "2023-07-31T10:44:56Z")

</div>

Have a look at the Join node, for joining your inputs into one message. See [this article in the cookbook](https://cookbook.nodered.org/basic/join-streams) for an example of how to join messages into one object.

---

<div class="post-metadata">

**Author:** ![Popolackie](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@Popolackie](https://discourse.nodered.org/u/Popolackie)\
**Post date:** [31 July 2023 11:53 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184/3 "2023-07-31T11:53:10Z")

</div>

Hi, I tried the following

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd43a819bfcd3fee4bc39bc1474f7a537642ee50.png)  
( 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!

---

<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:** [31 July 2023 12:40 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184/4 "2023-07-31T12:40:44Z")

</div>

> [@Popolackie](#):
>
> could you explain how to post a snippet?

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](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

> [@Popolackie](#):
>
> Every message comming in then should be propageted to either one or the other direction. Not waiting fpr three messages

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.

---

<div class="post-metadata">

**Author:** ![Popolackie](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@Popolackie](https://discourse.nodered.org/u/Popolackie)\
**Post date:** [31 July 2023 17:06 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184/5 "2023-07-31T17:06:08Z")

</div>

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] ?

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

```

---

<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:** [31 July 2023 17:18 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184/6 "2023-07-31T17:18:01Z")

</div>

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) 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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<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:** [30 August 2023 17:18 UTC](https://discourse.nodered.org/t/switching-between-two-analogue-values-manual-automatic-with-a-dashboard-switch/80184/7 "2023-08-30T17:18:11Z")

</div>

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