Button node - passthrough?

#1

The dashboard button config contains this -

button

...which suggests if you stick an inject node in front of the button node, the msg from the inject node should pass through the button node and appear in debug.

button2

But it doesn't, it just sends the payload contained in the button node, and the msg from the inject node is disregarded.

My user case was to chain a number of buttons together, each of which performs a different function, and the single output then influences further processes.

button3

The flow for the 3 node example above;

[
    {
        "id": "d87ba0f9.de993",
        "type": "ui_button",
        "z": "6eb37a1d.ee8f34",
        "name": "button",
        "group": "ddd690d2.0351d",
        "order": 5,
        "width": "2",
        "height": "1",
        "passthru": true,
        "label": "test",
        "color": "green",
        "bgcolor": "#2A2A2A",
        "icon": "",
        "payload": "fromButton",
        "payloadType": "str",
        "topic": "",
        "x": 750,
        "y": 540,
        "wires": [
            [
                "8bdb8c06.f727f"
            ]
        ]
    },
    {
        "id": "8f4c010f.465cd",
        "type": "inject",
        "z": "6eb37a1d.ee8f34",
        "name": "inject",
        "topic": "",
        "payload": "fromInject",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 590,
        "y": 540,
        "wires": [
            [
                "d87ba0f9.de993"
            ]
        ]
    },
    {
        "id": "8bdb8c06.f727f",
        "type": "debug",
        "z": "6eb37a1d.ee8f34",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 900,
        "y": 540,
        "wires": []
    },
    {
        "id": "ddd690d2.0351d",
        "type": "ui_group",
        "z": "",
        "name": "Test2",
        "tab": "117b6717.6166b9",
        "disp": true,
        "width": "27",
        "collapse": false
    },
    {
        "id": "117b6717.6166b9",
        "type": "ui_tab",
        "z": 0,
        "name": "Test2",
        "icon": "dashboard",
        "order": 7
    }
]
0 Likes

#2

The button will only send a payload if the input matches the expected output - ie it acts like you pressed the button - it is not a general passthru. It will pass through all the other properties - so you can use those to tell if it was a simulated click or a real click.

Why not just wire all four buttons into the function node ?

0 Likes

#3

It's easy to workaround, but maybe that needs clarifying in the node info.
I read 'If msg arrives on input, pass through to output' in a different context, meaning what goes in, comes out.

0 Likes

#4

Also, it seems to send the button node msg even if the incoming message doesn't match.

0 Likes

#5

sorry - was mixing it up with the switch node.

0 Likes

#6

Could I have some clarity on this please;
Is it a bug, or am I misinterpreting the node help/readme?

Paul

0 Likes

#7

If set to pass through mode a message arriving on the input will act like pressing the button. The output payload will be as defined in the node configuration.

0 Likes

#8

OK thanks.
In that case I'll move to plan B!

0 Likes

#9

@dceejay - so If `msg` arrives on input, pass through to output: doesn't actually pass the msg object out? If I have an inject node sending 'hello button' connected to a button that is connected to a debug, the debug will not show 'hello buton', it will show what ever is in When clicked, send:

Maybe the statement should read If `msg` arrives on input, it will trigger an automatic button push

1 Like

#10

Well no.. I said the payload is set to whatever is configured... The rest of the msg and other properties are passed through. When pressing the button you only get payload and optional topic.

0 Likes

#11

But isn't that what Paul Z is saying?

Button push = " Clicking the button generates a message with msg.payload set to the Payload field."

Paul

0 Likes

#12

As far as the payload goes yes. The rest of the msg may well be different.

0 Likes

#13

...but his statement is not wrong, and probably makes more sense than what we presently have.

From a user perspective, the current wording is misleading.

1 Like

#14

My first response to you tonight was cut/pasted from the latest (master) info panel.

0 Likes

#15

I did check first, but I'm not seeing that - https://github.com/node-red/node-red-dashboard/blob/master/nodes/ui_button.html

0 Likes

#16

To sumarize:

If passthru is NOT checked, any flow msg entering the ui_node will go no further - it's a dead end. The only time a msg will leave the node is when the button is pushed on the dashboard.

If pastthru IS checked and a msg enters the ui_node, all parts of the msg except payload and topic will remain unchanged. For payload and topic the following applies:

  • payload - will becone the value set in the ui_button or if it is left blank, it becomes the id of the ui-button (for example: payload: "4b7e1b33.5b482c")
  • topic - will become the value set in the ui_button node or if left blank, the existing msg.topic will not change.
1 Like