# Button node: If msg arrives on input, emulate a button click:

**URL:** https://discourse.nodered.org/t/button-node-if-msg-arrives-on-input-emulate-a-button-click/26477
**Category:** General
**Created:** [11 May 2020 11:52 UTC](https://discourse.nodered.org/t/button-node-if-msg-arrives-on-input-emulate-a-button-click/26477 "2020-05-11T11:52:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [11 May 2020 11:52 UTC](https://discourse.nodered.org/t/button-node-if-msg-arrives-on-input-emulate-a-button-click/26477/1 "2020-05-11T11:52:49Z")

</div>

I've been caught on this before I think but want to check.

What exactly does that mean?

This is the code this time:

```auto
[{"id":"d3c31e8d.90ed7","type":"ui_button","z":"caed37a2.771dc","name":"","group":"6ab22327.a2f71c","order":18,"width":"2","height":"1","passthru":true,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"3","payloadType":"num","topic":"","x":330,"y":380,"wires":[["6741e2f8.7766f4"]]},{"id":"f2826600.de653","type":"inject","z":"caed37a2.771dc","name":"","topic":"","payload":"8","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":380,"wires":[["d3c31e8d.90ed7"]]},{"id":"6741e2f8.7766f4","type":"debug","z":"caed37a2.771dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":510,"y":380,"wires":[]},{"id":"6ab22327.a2f71c","type":"ui_group","z":"","name":"HOME","tab":"273de47d.2d2bac","order":1,"disp":true,"width":3,"collapse":false},{"id":"273de47d.2d2bac","type":"ui_tab","z":"","name":"TEST","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

```

I `inject` a value of `8` and go through the `button`.  
But I get a `3` in the `debug` node.

So the `emulate a button click` means **forget what is sent in, you are getting the output as though the button was pressed**.

Not just pass the message through.

On the `switch` node (dashboard) it says this:

> Pass though `msg` if payload matches new state

How does this compare to the button's _pass through_?

> **If payload matches new state**

So sorry for the brain failure.  
But I just want to check.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [11 May 2020 12:29 UTC](https://discourse.nodered.org/t/button-node-if-msg-arrives-on-input-emulate-a-button-click/26477/2 "2020-05-11T12:29:40Z")

</div>

Emulate button click means exactly that, it is like pressing the button.

In your button node, you say 'send 3 when the button is pushed' so that is what is send whether you press the button or send a msg to the button which acts like you pressed the button - 3 gets sent out in msg payload,

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [12 May 2020 00:15 UTC](https://discourse.nodered.org/t/button-node-if-msg-arrives-on-input-emulate-a-button-click/26477/3 "2020-05-12T00:15:40Z")

</div>

I know it was (probably) a stupid question, it just caught me out - maybe again.

---

<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: [26 May 2020 00:15 UTC](https://discourse.nodered.org/t/button-node-if-msg-arrives-on-input-emulate-a-button-click/26477/4 "2020-05-26T00:15:46Z")

</div>

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