# How to test function using numeric node?

**URL:** <https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363>\
**Category:** General\
**Created:** [17 December 2021 20:36 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363 "2021-12-17T20:36:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [17 December 2021 20:36 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/1 "2021-12-17T20:36:39Z")

</div>

Hi all,

I have written a function in a function node which I want to test using a numeric node by changing the input values. I have to emulate the message you can see in the screenshot below. Only value _ **msg.payload.power** _ is of interest.

Is it possible to configure the numeric node directly accordingly?  
Or do I have to add a function which creates value _ **msg.payload.power** _ based on the input of the numeric node?  
If so, how in detail this can be done?

Thx!

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

---

<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:** [17 December 2021 20:46 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/2 "2021-12-17T20:46:33Z")

</div>

Is this what you mean?

```auto
[{"id":"e64a3fc9aceb70f9","type":"inject","z":"7e987ddf260bdf0d","name":"","props":[{"p":"payload.power","v":"284","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":250,"y":2870,"wires":[["ad40a24c5e44b6cf"]]},{"id":"ad40a24c5e44b6cf","type":"debug","z":"7e987ddf260bdf0d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":420,"y":2870,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 December 2021 20:57 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/3 "2021-12-17T20:57:18Z")

</div>

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

Note however, for functions, you access this via the `msg` object. So in your case `msg.payload.power`

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [17 December 2021 21:00 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/4 "2021-12-17T21:00:15Z")

</div>

Hi Andrew and Stephen,

thank you for your quick responses.

I have now managed the issue using this (a _ **change node** _ between _ **numeric node** _ and the function I want to test:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/6/06220690ac4aac20215a4ea866b13089f7301d36.png)

---

<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:** [17 December 2021 21:17 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/5 "2021-12-17T21:17:44Z")

</div>

Good to hear you got it working.

Ok, you show you use the `change` node to _move_ the `msg.payload` to `msg.payload.power`.

Only to save moving so much around, look further back and explain _who_ (what?) is sending the `msg.payload` which you then send into this `change` node?

I'll stop there so as to not overwhelm you.

Maybe do a screen shot of the nodes showing what is before the `change` node.  
Not all the way, but say a few nodes to start with.

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [17 December 2021 21:23 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/6 "2021-12-17T21:23:08Z")

</div>

> [@Trying\_to\_learn](#):
>
> the `msg.payload` to `msg.payload.power` .

What do I have to do to have this special formatting (grey background and red text)?

---

<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:** [17 December 2021 21:30 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/7 "2021-12-17T21:30:33Z")

</div>

> [@nosered1966](#):
>
> What do I have to do to have this special formatting (grey background and red text)?

It is difficult to say as when I use the keys, they are not shown.

Just to the left of the `1` key is a key (usually) which has a `~` and a ' (nearly) on it.

If it is one line you do this  
`this is an example of one line`  
which from the keyboard's point of view is: (using the wrong key only to show you)  
'this is an example of one line'

But it isn't the key to the right of the `;` key. It is the key to the left of the `1` key.

If you want to post multiple lines (or a long line of text) you do it this way:  
'''  
a lot of stuff here  
with a lot of lines  
'''

And it comes out like this - really:

```auto
a lot of stuff here
with a lot of lines

```

Does that help?

Basically the latter is like pressing the `</>` button at the top of the area where you enter your text.

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [17 December 2021 21:40 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/8 "2021-12-17T21:40:05Z")

</div>

I think I have a german keyboard...

Using "\</\>" from editor it looks like this (when editing green on grey background):

```auto
aaaa

```

The rest you have written sounds to me like a big mystery.  
😉  
May be it is because English is not my native language.  
But thank you very much for your help!

---

<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:** [31 December 2021 21:40 UTC](https://discourse.nodered.org/t/how-to-test-function-using-numeric-node/55363/9 "2021-12-31T21:40:49Z")

</div>

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