What's going on here - switch node

I think I know what's going on. It's the payload attribute. Do this:

  1. create inject node and set the payload attribute to something
  2. add a second attribute and call it payload aswell, set it to a different value

  1. Close the edit panel with done
  2. open the edit panel and the payload value is the same:

That's because the payload attribute is handled separately in the inject node:

[
    {
        "id": "fec30d0fd480bbf4",
        "type": "inject",
        "z": "5c82c4b32e500961",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "snafu",  // <<<<<--------- payload can only have one value
        "payloadType": "str",
        "x": 1180,
        "y": 623,
        "wires": [
            []
        ]
    }
]

it's probably something similar in the switch node - the attribute being used is also called payload in the example here.

EDIT: damn, just checked - it's not!

1 Like

Honestly, I can't say.

I just noticed it when I was trying to use the second output and wasn't getting it.

So I opened the node and saw the anomaly.

Wow, that is smart. Even if wrong. No offense.

How you analised the situation and made a test bed.

I'll give it a go just for the fun of it and get back to you.

Sharing.

[
    {
        "id": "d2c1c0ab4e2a80d5",
        "type": "inject",
        "z": "b25fd092.bcc758",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "bar",
        "payloadType": "str",
        "x": 2950,
        "y": 2000,
        "wires": [
            []
        ]
    }
]

Alas the foo did get lost when I closed the inject node.

When I reopened it both lines were bar. foo had gone.

I had this situation with the inject node a while back but I assumed it's a known issue and there isn't anything that can be done - because of backward compatibility.

I had it because I sometimes add the same attribute multiple times to have different values (for testing). I then only need to move the defintions up and down using the drag & drop in the inject node instead of replacing the value - by typing. I was going to do this with the payload attribute and discovered this bug ...

It's a pity that's its not the fix for the switch node :wink:

No offence taken!