# Need help and I'm an absolute beginner

**URL:** <https://discourse.nodered.org/t/need-help-and-im-an-absolute-beginner/61680>\
**Category:** General\
**Tags:** function-node\
**Created:** [23 April 2022 11:52 UTC](https://discourse.nodered.org/t/need-help-and-im-an-absolute-beginner/61680 "2022-04-23T11:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![logol01](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@logol01](https://discourse.nodered.org/u/logol01)\
**Post date:** [23 April 2022 11:52 UTC](https://discourse.nodered.org/t/need-help-and-im-an-absolute-beginner/61680/1 "2022-04-23T11:52:43Z")

</div>

I will create an Flow, where the Friends of hue Switch (there are 4 Buttons) send an 1 to garden door if I press the button.

I don't know which node I have to use for that and I have no idea how I get an "1" to the "Gartentor" output.... so long I press the Button 1.

In the picutre attached you see, what I get on the Debug Note, when I press the Button 1.

I would be really a pleasure, if someone helps me... I have no Idea.....

Thanks a lot

 ![2022-04-22 23_20_58-Einstellungen](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/4/64e6af8e206bd51c20a54519184123d5a928b56e.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 April 2022 12:07 UTC](https://discourse.nodered.org/t/need-help-and-im-an-absolute-beginner/61680/2 "2022-04-23T12:07:55Z")

</div>

Hi @logol01, welcome.

first you need to use the switch node to route your message according to the action, then using a change node you can set the payload to what ever you require.  
If you use a debug node and use the copy value button that appears when you hover near the object name, you can then post a copy of the incoming objects. I could then use that to post an example flow for you.

You should take some time and read through the node-red docs and watch the videos, as this will help you understand many things, including how to share info and how message routing work and how to share flows, import/export.  
When sharing code on this forum it is best to use the \</\> button in the post editor

---

<div class="post-metadata">

**Author:** ![logol01](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@logol01](https://discourse.nodered.org/u/logol01)\
**Post date:** [27 April 2022 10:25 UTC](https://discourse.nodered.org/t/need-help-and-im-an-absolute-beginner/61680/3 "2022-04-27T10:25:15Z")

</div>

I found an other solution....  
This works perfect for my Problem.

I used a fuction node with the following code:

```auto
const Button = msg.payload.button;
const Action = msg.payload.action;

if(Button === 1 && Action === 'initial_press'){
return {payload: 1}
}
if(Button === 1 && Action === 'short_release'){
return {payload: 0}
}
return msg;

```

 ![2022-04-27 10_58_36-Node-RED _ 192.168.178.10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9321bb66c4177dff507bfb36bcb85923e008dc3.png)

---

<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 June 2022 10:25 UTC](https://discourse.nodered.org/t/need-help-and-im-an-absolute-beginner/61680/4 "2022-06-26T10:25:22Z")

</div>

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