How to test function using numeric node?

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

Is this what you mean?

[{"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":[]}]
1 Like

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

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

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

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.

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:

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.

I think I have a german keyboard...

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

aaaa

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

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