# Dashboard switch status

**URL:** <https://discourse.nodered.org/t/dashboard-switch-status/93866>\
**Category:** Dashboard\
**Tags:** switch-node\
**Created:** [11 December 2024 23:05 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866 "2024-12-11T23:05:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![horemansp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/horemansp/32/97139_2.png) [@horemansp](https://discourse.nodered.org/u/horemansp)\
**Post date:** [11 December 2024 23:05 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/1 "2024-12-11T23:05:19Z")

</div>

I was wondering if you can change the switch status via the input msg.payload true/false.  
My switch is configured to send "led=on" when switched on and "led=off" when switched off.  
Now I'm looking to control the switch status (being on or off) of the switch node input.  
When I send payload true or false to the switch it is not reacting.

```auto
[
    {
        "id": "1676caabf9fcc6ab",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f90a8137d98f0b15",
        "type": "ui_switch",
        "z": "1676caabf9fcc6ab",
        "name": "",
        "label": "switch",
        "tooltip": "",
        "group": "9b4c9f0652de40c1",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "led=on",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "led=off",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 430,
        "y": 240,
        "wires": [
            [
                "8eb0a96075dbe348"
            ]
        ]
    },
    {
        "id": "47c6eb84fc14fa2c",
        "type": "inject",
        "z": "1676caabf9fcc6ab",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 150,
        "y": 160,
        "wires": [
            [
                "f90a8137d98f0b15"
            ]
        ]
    },
    {
        "id": "0449832fb66ee4d9",
        "type": "inject",
        "z": "1676caabf9fcc6ab",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 150,
        "y": 300,
        "wires": [
            [
                "f90a8137d98f0b15"
            ]
        ]
    },
    {
        "id": "8eb0a96075dbe348",
        "type": "debug",
        "z": "1676caabf9fcc6ab",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 240,
        "wires": []
    },
    {
        "id": "9b4c9f0652de40c1",
        "type": "ui_group",
        "name": "Controls",
        "tab": "b2a154f296011832",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "b2a154f296011832",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [11 December 2024 23:45 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/2 "2024-12-11T23:45:04Z")

</div>

Welcome to the foum @horemansp

> [@horemansp](#):
>
> My switch is configured to send "led=on" when switched on and "led=off" when switched off.  
> When I send payload true or false to the switch it is not reacting.

What happens if your inject nodes send "led=on" or "led=off" instead of true and false?

---

<div class="post-metadata">

**Author:** ![MyRandomThoughts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myrandomthoughts/32/41085_2.png) [@MyRandomThoughts](https://discourse.nodered.org/u/MyRandomThoughts)\
**Post date:** [12 December 2024 11:14 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/3 "2024-12-12T11:14:34Z")

</div>

According to the built-in help for that node:

> In pass through mode the switch state can be updated by an incoming `msg.payload` with the specified values, that must also match the specified type (number, string, etc). When not in passthrough mode then the icon can either track the state of the output - or the input msg.payload, in order to provide a closed loop feedback.

---

<div class="post-metadata">

**Author:** ![horemansp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/horemansp/32/97139_2.png) [@horemansp](https://discourse.nodered.org/u/horemansp)\
**Post date:** [12 December 2024 14:18 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/4 "2024-12-12T14:18:38Z")

</div>

Then it works. That's not how I expected it to work though.

---

<div class="post-metadata">

**Author:** ![horemansp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/horemansp/32/97139_2.png) [@horemansp](https://discourse.nodered.org/u/horemansp)\
**Post date:** [12 December 2024 14:20 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/5 "2024-12-12T14:20:48Z")

</div>

I don't want it to pass through because then it would create a loop.  
If I change the state to

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d5b27784c4a04a3d5d3ec2963d8a28abb212c7c.png)  
Then I can't control the switch manually anymore.  
If I change it to  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f4f74f547c75c9dad80241f21b0b1712f1d43bd.png)  
Then it won't reflect the actually state...

---

<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:** [12 December 2024 16:23 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/6 "2024-12-12T16:23:38Z")

</div>

> [@horemansp](#):
>
> Then it won't reflect the actually state...

Feed the output back to the input, or use it in pass through mode with a Filter node on the output to break the loop.

---

<div class="post-metadata">

**Author:** ![horemansp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/horemansp/32/97139_2.png) [@horemansp](https://discourse.nodered.org/u/horemansp)\
**Post date:** [12 December 2024 16:24 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/7 "2024-12-12T16:24:27Z")

</div>

That works!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b9ee80962f91d43e082b52369e6563e9dca58009.png)

---

<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:** [12 December 2024 16:25 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/8 "2024-12-12T16:25:06Z")

</div>

You don't need to use a Function node, you can use just a Junction node.

---

<div class="post-metadata">

**Author:** ![horemansp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/horemansp/32/97139_2.png) [@horemansp](https://discourse.nodered.org/u/horemansp)\
**Post date:** [12 December 2024 16:55 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/9 "2024-12-12T16:55:53Z")

</div>

Gotcha, did not knew about that, never used such a junction

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6a01116b8d4fe32fa70bfd8dec758fc73491a346.png)

---

<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:** [11 January 2025 16:56 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866/10 "2025-01-11T16:56:23Z")

</div>

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