Dashboard switch status

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.

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

Welcome to the foum @horemansp

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

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.

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

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


Then I can't control the switch manually anymore.
If I change it to

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.

That works!

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

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