# Button normally open

**URL:** <https://discourse.nodered.org/t/button-normally-open/75390>\
**Category:** Dashboard\
**Created:** [18 February 2023 12:02 UTC](https://discourse.nodered.org/t/button-normally-open/75390 "2023-02-18T12:02:30Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 12:02 UTC](https://discourse.nodered.org/t/button-normally-open/75390/1 "2023-02-18T12:02:30Z")

</div>

Hello everyone  
Reference to post [Momentary switch or button (normally open)](https://discourse.nodered.org/t/momentary-switch-or-button-normally-open/36768)  
I don't understand how to do it, I would like it to remain true when pressed and false when not pressed. I am trying to do it with an LED node but it stays locked on true (green).

Thank you very much

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [18 February 2023 16:58 UTC](https://discourse.nodered.org/t/button-normally-open/75390/2 "2023-02-18T16:58:59Z")

</div>

The momentary switch works as expected. How are using it, and with what LED node. Best if you upload your flow or the relevant part of it so that we can see why it doesn't work as you expect.

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 18:08 UTC](https://discourse.nodered.org/t/button-normally-open/75390/3 "2023-02-18T18:08:58Z")

</div>

With switch if the led works, I mean to do it with a push button while you keep pressed is true and if not pressed is false.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e9ddbed52567671607e5eb87853233bafa82ad5.png)

Thanks for your answer!

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [18 February 2023 19:13 UTC](https://discourse.nodered.org/t/button-normally-open/75390/4 "2023-02-18T19:13:32Z")

</div>

I'm sorry but I have no idea what the nodes X-forward and led are. Can you upload the flow rather than just a picture. If I search for led in the nodes it comes up with 112 nodes!

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 19:18 UTC](https://discourse.nodered.org/t/button-normally-open/75390/5 "2023-02-18T19:18:26Z")

</div>

I want to make a normally open button, that when you press it is true and when you stop pressing it is false. What is in the image is a 'switch' node and then a 'button' node with a name assigned by me, it is for the control of a motor.

Thank you very much

---

<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:** [18 February 2023 19:28 UTC](https://discourse.nodered.org/t/button-normally-open/75390/6 "2023-02-18T19:28:48Z")

</div>

Did you try the solution in the post you linked to at the start?

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [18 February 2023 19:29 UTC](https://discourse.nodered.org/t/button-normally-open/75390/7 "2023-02-18T19:29:04Z")

</div>

The momentary button sends TRUE when pressed and FALSE when released in the msg.payload. Open the browser dashboard to see the button and its action.

```auto
[{"id":"eac5d9eb.958798","type":"ui_template","z":"6d08d5ab.a8aa3c","group":"61e6d4c4.e7619c","name":"momentary button","order":7,"width":"1","height":"1","format":"<div id=\"momentary\">\n <md-button style=\"min-width:36px;\n width: 100%; \n height: 100%; \n margin:0; \n padding: 0px; \n border-radius: 50%; \n background-color:green\">\n \n <i class=\"fa fa-hand-pointer-o\"></i>\n </md-button>\n</div>\n<script>\n(function($scope) {\n \n$('#momentary').on('touchstart mousedown', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"topic\":\"momentary\",\"payload\": true});\n});\n\n$('#momentary').on('touchend mouseup', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"topic\":\"momentary\",\"payload\": false});\n});\n \n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":360,"y":140,"wires":[["534f375d.fce978"]]},{"id":"534f375d.fce978","type":"debug","z":"6d08d5ab.a8aa3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":140,"wires":[]},{"id":"61e6d4c4.e7619c","type":"ui_group","name":"TEST","tab":"d680797a.2f8b88","order":1,"disp":true,"width":"5","collapse":false},{"id":"d680797a.2f8b88","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 20:00 UTC](https://discourse.nodered.org/t/button-normally-open/75390/8 "2023-02-18T20:00:29Z")

</div>

I don't know where to put the solution from the previous thread to create the push button. Where to put it?

Thank you very much

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 20:01 UTC](https://discourse.nodered.org/t/button-normally-open/75390/9 "2023-02-18T20:01:27Z")

</div>

That's right, where do I put that? I have tried in the node 'button' in payload: JSON and nothing.

Thank you very much

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [18 February 2023 20:12 UTC](https://discourse.nodered.org/t/button-normally-open/75390/10 "2023-02-18T20:12:50Z")

</div>

Did you down load the code by copying it? When you put your cursor over the code in my post you will see in the top right corner a copy icon or expand icon. Click on the copy icon. In Node Red click on the hamburger top right and then Import in the dropdown menu. Paste the code you copied from the post to import it.

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 20:20 UTC](https://discourse.nodered.org/t/button-normally-open/75390/11 "2023-02-18T20:20:27Z")

</div>

It works! How can I change the appearance of the 'button' node type?

Thank you very much

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [18 February 2023 20:22 UTC](https://discourse.nodered.org/t/button-normally-open/75390/12 "2023-02-18T20:22:30Z")

</div>

If you double click on the momentary button in the Node Red editor you will be able to edit the ui\_template node.

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 20:39 UTC](https://discourse.nodered.org/t/button-normally-open/75390/13 "2023-02-18T20:39:33Z")

</div>

Thank you very much

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [18 February 2023 21:07 UTC](https://discourse.nodered.org/t/button-normally-open/75390/14 "2023-02-18T21:07:55Z")

</div>

Hi again,

hello again,

hello again,

I have put two pushbuttons, each connected to its node. The first one turns on both the first 'led' node and the second 'led' node but the second 'led' node is not connected to the first pushbutton, and second pushbutton

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/c/7c6264a0ce90d5f7adfb8ace6d582bbcd7c21a99.png)

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

Thank you!

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [20 February 2023 12:35 UTC](https://discourse.nodered.org/t/button-normally-open/75390/15 "2023-02-20T12:35:31Z")

</div>

Without seeing your actual flow, rather than a snapshot, then it is difficult to know what you are doing wrong. For instructions on how to post a flow onto the forum, please read [here](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506).

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [3 March 2023 17:29 UTC](https://discourse.nodered.org/t/button-normally-open/75390/16 "2023-03-03T17:29:49Z")

</div>

The solution to create several, is to change the id to "momentary".

Thank you very much

---

<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:** [17 March 2023 17:30 UTC](https://discourse.nodered.org/t/button-normally-open/75390/17 "2023-03-17T17:30:12Z")

</div>

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