Msg.payload help

Hello All,

I am having issues converting a message payload ex ample value from debug "15" to '15'. I need the payload to be in the format 'x' so that my function node will work.

[{"id":"4d9bb02d.3c221","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"f0379573.07efb8","type":"inject","z":"4d9bb02d.3c221","name":"","topic":"","payload":"\"ip\":10.10.10.10\"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":2000,"y":280,"wires":[["c1ad69cb.940f48","789e8b45.05cc24"]]},{"id":"c1ad69cb.940f48","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2210,"y":280,"wires":[["e4a308f7.2638f8","409633ae.7428ac"]]},{"id":"e4a308f7.2638f8","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"ip","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2410,"y":280,"wires":[["5b20cab0.d9d224","b3a10295.f21af"]]},{"id":"5b20cab0.d9d224","type":"split","z":"4d9bb02d.3c221","name":"","splt":":","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":2570,"y":280,"wires":[["6671f7b4.7e6248","30294987.0bd8c6"]]},{"id":"6671f7b4.7e6248","type":"switch","z":"4d9bb02d.3c221","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"10.10","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":2710,"y":280,"wires":[["6a44a2ae.c0bd8c","7c690a00.459d38"],[]]},{"id":"6a44a2ae.c0bd8c","type":"json","z":"4d9bb02d.3c221","name":"","property":"payload","action":"str","pretty":false,"x":2850,"y":280,"wires":[["89572b0b.3b98f8","db28a337.e513e"]]},{"id":"89572b0b.3b98f8","type":"function","z":"4d9bb02d.3c221","name":"","func":"var m =msg.payload[0].value;\nreturn msg;","outputs":1,"noerr":0,"x":2990,"y":280,"wires":[["3939e7b5.1b0588","396d35be.8f75fa"]]},{"id":"3939e7b5.1b0588","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3170,"y":280,"wires":[["3fc9d158.1a921e"]]},{"id":"3fc9d158.1a921e","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3320,"y":220,"wires":[]},{"id":"789e8b45.05cc24","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2210,"y":200,"wires":[]},{"id":"409633ae.7428ac","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2370,"y":220,"wires":[]},{"id":"b3a10295.f21af","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2530,"y":220,"wires":[]},{"id":"30294987.0bd8c6","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2670,"y":220,"wires":[]},{"id":"7c690a00.459d38","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2830,"y":220,"wires":[]},{"id":"db28a337.e513e","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2990,"y":220,"wires":[]},{"id":"396d35be.8f75fa","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3137,"y":224,"wires":[]}]

The msg.payload originating from the inject node is;

inject
Are you sure that is correct?

I used the inject node to pass the message that is obtain from a text input node. The full flow has this msg.payload the saved to the pi the retrieved from the pi. Full flow below.

[{"id":"4d9bb02d.3c221","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"5bbc5d7b.141e84","type":"ui_text_input","z":"4d9bb02d.3c221","name":"IP Address of Controller","label":"IP Address of Controller","tooltip":"","group":"3487420a.cf479e","order":4,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"","x":1450,"y":140,"wires":[["74a3ba2.5c55d44"]]},{"id":"74a3ba2.5c55d44","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1890,"y":140,"wires":[["362e5ad6.79f686"]]},{"id":"362e5ad6.79f686","type":"join","z":"4d9bb02d.3c221","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2110,"y":140,"wires":[["a217d379.2c718","285ec233.4d192e"]]},{"id":"285ec233.4d192e","type":"function","z":"4d9bb02d.3c221","name":"Data Capture","func":"var d = new Date();\nvar t = d.getTime();\nvar n = d.getTimezoneOffset();\npayload={\"date/time\": d,\"Time Zone Diffrence in minutes\": n,\"IP\": msg.ip,\"Bacnet\": msg.Bacnet, \"Function\": msg.Function, \"type\": msg.ObjectID,\"App Tag\": msg.Apptag, \"Property ID\": msg.PropertyID, \"Write Value\": msg.Wvalue, \"payload\":msg.payload};\nmsg.payload=payload;\nreturn msg;","outputs":1,"noerr":0,"x":2350,"y":360,"wires":[["e62980d8.db7fb"]]},{"id":"a217d379.2c718","type":"ui_text","z":"4d9bb02d.3c221","group":"998b684b.3b4e88","order":2,"width":0,"height":0,"name":"","label":"IP Address","format":"{{ip}}","layout":"col-center","x":2350,"y":120,"wires":[]},{"id":"e62980d8.db7fb","type":"json","z":"4d9bb02d.3c221","name":"","property":"payload","action":"","pretty":false,"x":2510,"y":360,"wires":[["44ddf002.82251"]]},{"id":"44ddf002.82251","type":"file","z":"4d9bb02d.3c221","name":"Add Device file location","filename":"/home/pi/hvac/NewDevice.log","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":2710,"y":360,"wires":[[]]},{"id":"b34ea623.c1c078","type":"ui_button","z":"4d9bb02d.3c221","name":"","group":"3487420a.cf479e","order":10,"width":0,"height":0,"passthru":false,"label":"Check Device (can take up to 2 mins)","tooltip":"","color":"red","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":1410,"y":740,"wires":[["83a04ee8.e326"]]},{"id":"83a04ee8.e326","type":"file in","z":"4d9bb02d.3c221","name":"","filename":"/home/pi/hvac/NewDevice.log","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":1730,"y":740,"wires":[["5f393ae0.505b44"]]},{"id":"5f393ae0.505b44","type":"split","z":"4d9bb02d.3c221","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1950,"y":740,"wires":[["603d4f79.e86cd"]]},{"id":"603d4f79.e86cd","type":"switch","z":"4d9bb02d.3c221","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"IP\":","vt":"str"},{"t":"cont","v":"\"Bacnet\":","vt":"str"},{"t":"cont","v":"\"Function\":","vt":"str"},{"t":"cont","v":"\"type\":","vt":"str"},{"t":"cont","v":"\"App Tag\":","vt":"str"},{"t":"cont","v":"\"Property ID\":","vt":"str"},{"t":"cont","v":"\"Write Value\":","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":2110,"y":740,"wires":[["e62753b2.604bc"],[],[],[],[],[],[]]},{"id":"e62753b2.604bc","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2350,"y":640,"wires":[["fa58e6f8.8b1918"]]},{"id":"fa58e6f8.8b1918","type":"join","z":"4d9bb02d.3c221","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"7","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2610,"y":760,"wires":[["e3fb75ff.25a1e8"]]},{"id":"e3fb75ff.25a1e8","type":"switch","z":"4d9bb02d.3c221","name":"","property":"Function","propertyType":"jsonata","rules":[{"t":"cont","v":"\"Function\":\"Read Function\"","vt":"str"},{"t":"cont","v":"\"Function\":\"Write Function\"","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2750,"y":760,"wires":[["bf633d4d.c1e2"],[]]},{"id":"bf633d4d.c1e2","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"ip","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2930,"y":520,"wires":[["c740d937.ea3ee8"]]},{"id":"c740d937.ea3ee8","type":"split","z":"4d9bb02d.3c221","name":"","splt":":","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":3130,"y":520,"wires":[["252d88ba.f77438"]]},{"id":"252d88ba.f77438","type":"switch","z":"4d9bb02d.3c221","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"192.168","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":3270,"y":520,"wires":[["fd4a523e.519ac"],[]]},{"id":"fd4a523e.519ac","type":"json","z":"4d9bb02d.3c221","name":"","property":"payload","action":"","pretty":false,"x":3410,"y":520,"wires":[["92887c96.4d0bb"]]},{"id":"92887c96.4d0bb","type":"function","z":"4d9bb02d.3c221","name":"","func":"var m =msg.payload[0].value;\nreturn msg;","outputs":1,"noerr":0,"x":3630,"y":520,"wires":[["9ee535e2.af73d8"]]},{"id":"9ee535e2.af73d8","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3810,"y":520,"wires":[["785296e9.076078"]]},{"id":"785296e9.076078","type":"join","z":"4d9bb02d.3c221","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"10","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":4020,"y":600,"wires":[["d73b2463.42ad28"]]},{"id":"d73b2463.42ad28","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":4190,"y":540,"wires":[]},{"id":"3487420a.cf479e","type":"ui_group","z":"","name":"Manual Device check","tab":"99082a6.ab01ed8","order":2,"disp":true,"width":"10","collapse":true},{"id":"998b684b.3b4e88","type":"ui_group","z":"","name":"Verify Data","tab":"99082a6.ab01ed8","order":3,"disp":true,"width":"6","collapse":true},{"id":"99082a6.ab01ed8","type":"ui_tab","z":"","name":"Testing","icon":"dashboard","order":12,"disabled":false,"hidden":false}]

I haven't tried your full flow because it's about 4 screen widths wide!!, but I would suggest looking at the format of the input, as the screenshot that I pasted above of what you are injecting is clearly not structured correctly.

Looks like exactly the same issue as your post yesterday. Please don’t open new issues for the same issue

Not the same issue. I was able to remove the doubles quotes, by adding a json node and a function node. The new issue is the msg.payload need to be in a string format with ' instead of ".

See below i cleaned it up a little more. The input works for the 5 other values that is being collected.

Now the only thing is the string format needs to be changed from " to '.

[{"id":"4d9bb02d.3c221","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"5bbc5d7b.141e84","type":"ui_text_input","z":"4d9bb02d.3c221","name":"IP Address of Controller","label":"IP Address of Controller","tooltip":"","group":"7d8dabf3.e28c04","order":4,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"","x":190,"y":80,"wires":[["74a3ba2.5c55d44"]]},{"id":"74a3ba2.5c55d44","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":80,"wires":[["362e5ad6.79f686"]]},{"id":"362e5ad6.79f686","type":"join","z":"4d9bb02d.3c221","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":80,"wires":[["a217d379.2c718","285ec233.4d192e"]]},{"id":"285ec233.4d192e","type":"function","z":"4d9bb02d.3c221","name":"Data Capture","func":"var d = new Date();\nvar t = d.getTime();\nvar n = d.getTimezoneOffset();\npayload={\"date/time\": d,\"Time Zone Diffrence in minutes\": n,\"IP\": msg.ip,\"Bacnet\": msg.Bacnet, \"Function\": msg.Function, \"type\": msg.ObjectID,\"App Tag\": msg.Apptag, \"Property ID\": msg.PropertyID, \"Write Value\": msg.Wvalue, \"payload\":msg.payload};\nmsg.payload=payload;\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":80,"wires":[["e62980d8.db7fb"]]},{"id":"a217d379.2c718","type":"ui_text","z":"4d9bb02d.3c221","group":"7d8dabf3.e28c04","order":2,"width":0,"height":0,"name":"","label":"IP Address","format":"{{ip}}","layout":"col-center","x":790,"y":40,"wires":[]},{"id":"e62980d8.db7fb","type":"json","z":"4d9bb02d.3c221","name":"","property":"payload","action":"","pretty":false,"x":950,"y":80,"wires":[["44ddf002.82251"]]},{"id":"44ddf002.82251","type":"file","z":"4d9bb02d.3c221","name":"Add Device file location","filename":"/home/pi/hvac/NewDevice.log","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":1150,"y":80,"wires":[[]]},{"id":"b34ea623.c1c078","type":"ui_button","z":"4d9bb02d.3c221","name":"","group":"7d8dabf3.e28c04","order":10,"width":0,"height":0,"passthru":false,"label":"Check Device (can take up to 2 mins)","tooltip":"","color":"red","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":170,"y":260,"wires":[["83a04ee8.e326"]]},{"id":"83a04ee8.e326","type":"file in","z":"4d9bb02d.3c221","name":"","filename":"/home/pi/hvac/NewDevice.log","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":490,"y":260,"wires":[["5f393ae0.505b44"]]},{"id":"5f393ae0.505b44","type":"split","z":"4d9bb02d.3c221","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":710,"y":260,"wires":[["603d4f79.e86cd"]]},{"id":"603d4f79.e86cd","type":"switch","z":"4d9bb02d.3c221","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"IP\":","vt":"str"},{"t":"cont","v":"\"Bacnet\":","vt":"str"},{"t":"cont","v":"\"Function\":","vt":"str"},{"t":"cont","v":"\"type\":","vt":"str"},{"t":"cont","v":"\"App Tag\":","vt":"str"},{"t":"cont","v":"\"Property ID\":","vt":"str"},{"t":"cont","v":"\"Write Value\":","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":850,"y":260,"wires":[["e62753b2.604bc"],[],[],[],[],[],[]]},{"id":"e62753b2.604bc","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":220,"wires":[["fa58e6f8.8b1918"]]},{"id":"fa58e6f8.8b1918","type":"join","z":"4d9bb02d.3c221","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"7","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1210,"y":220,"wires":[["e3fb75ff.25a1e8"]]},{"id":"e3fb75ff.25a1e8","type":"switch","z":"4d9bb02d.3c221","name":"","property":"Function","propertyType":"jsonata","rules":[{"t":"cont","v":"\"Function\":\"Read Function\"","vt":"str"},{"t":"cont","v":"\"Function\":\"Write Function\"","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1350,"y":220,"wires":[["bf633d4d.c1e2"],[]]},{"id":"bf633d4d.c1e2","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"ip","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1510,"y":220,"wires":[["c740d937.ea3ee8"]]},{"id":"c740d937.ea3ee8","type":"split","z":"4d9bb02d.3c221","name":"","splt":":","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1670,"y":220,"wires":[["252d88ba.f77438"]]},{"id":"252d88ba.f77438","type":"switch","z":"4d9bb02d.3c221","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"192.168","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1810,"y":220,"wires":[["fd4a523e.519ac"],[]]},{"id":"fd4a523e.519ac","type":"json","z":"4d9bb02d.3c221","name":"","property":"payload","action":"","pretty":false,"x":1950,"y":220,"wires":[["92887c96.4d0bb"]]},{"id":"92887c96.4d0bb","type":"function","z":"4d9bb02d.3c221","name":"","func":"var m =msg.payload[0].value;\nreturn msg;","outputs":1,"noerr":0,"x":2090,"y":220,"wires":[["9ee535e2.af73d8"]]},{"id":"9ee535e2.af73d8","type":"change","z":"4d9bb02d.3c221","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2270,"y":220,"wires":[["785296e9.076078"]]},{"id":"785296e9.076078","type":"join","z":"4d9bb02d.3c221","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"10","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2450,"y":220,"wires":[["d73b2463.42ad28"]]},{"id":"d73b2463.42ad28","type":"debug","z":"4d9bb02d.3c221","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2590,"y":220,"wires":[]},{"id":"7d8dabf3.e28c04","type":"ui_group","z":"","name":"TEST","tab":"","disp":false,"width":"12","collapse":false}]

@Paul-Reed Below is a screen shot of the function node that it leads to.
but the msg.payload has to be in ' format not " to work.
image

Of the flow you've shared, which bit are we meant to be looking at?

From the screenshot you've just shared, do you mean you want to use the value of msg.ip in the place where you currently have the string '10.10.10.10' ?

Have you tried doing exactly that... replacing '10.10.10.10' with msg.ip?

In JavaScript, a String type can be surrounded by either " or ' - they are both valid (as long as they match at both ends).

If you pass a String type to Debug, it will display it surrounded by " to help indicated its a String type - but the " is not part of the actual data.

So the fact you have '10.10.10.10' surrounded by ' is kinda irrelevant - it would work just as well with "10.10.10.10" as that is exactly the same value.

I see Nick is replying, but I'll have a go.

I loaded your most recent flow.

1 - looking at the flow you posted I have to agree with @Paul-Reed. It is a wide flow.
Sure there is nothing wrong with that, but it makes it harder to get your head around.
2 - I am not seeing where the data is originating.

The top part of the flow does have a text input node. But it still isn't clear to me what is going on.

The lower part of the flow starts with a push button that injects a 1. I'm still not getting it.

You have just posted another part which includes a picture of a screen shot of a function node I can't find in the flow you posted.

I'd better stop now as I see Nick has beaten me to posting.

His questions will be better worded to find the problem than mine.

But another thing that may help is to put a few debug nodes in the flow so people can see how the message is developing through the flow.

The full flow can not be imported it is over the limit. I agree that normally it does not matter if surrounded by ' or ". But in order for the function to work the payload has to be surrounded by '.

the text input is being stored as a payload then converted from payload to. IP then joined with the other payloads that was converted. then they are displayed to the dashboard to make sure data is right before sending the full string with all the msg.x's to a log file on the pi (the reason for this is to have a log of that has been done). Then i am pulling the data from a log file and recompiling everything to be sorted on a value defined in the first flow. Then dumping and the msg.payloads into one function that i have to normally type all the values in to work. In the last screen shot i uploaded you can see by the var i have in the function this works for all except the var I = msg.ip; the reason for this is the msg.ip value is in the " format instead of the ' format.

I hope that made sense. and i am grateful that you all are trying to help.

Here is the dashboard view.

Please pass a message to Debug to display the value of msg.ip and show us the result so we can see for certain exactly what you've got.

Why does your function require the string to be surrounded by '?

That you for helping. I am also going to do screen shots.

Data being entered and sent

error on the node red side

It works when the function is like below

dashboard view when working

i hope this helps.

Not really, you have not answered what Nick asked...
Posting lots of screenshots is clouding your issue, it would be better to describe in words

image

Sorry, but I can't do a line by line comparison across two screenshots to figure out what you've changed.

When you say 'error on the node red side' which error in particular are we meant to be looking at?
When you say it works, there still an error in the sidebar... so what has worked?

The function of the read node sends out 2 payloads one has the payload of the values and the other does not. The one that does not have a payload returns the error.

it works whe i manually input the ip address as '192.168.1.41' but will not work if i use msg.ip or a var i put in place of msg.ip because the value that is being sent does not have 'before and after the ip address.

No. That is not what is happening here.

client.readProperty('192.168.1.41', { .........

There is absolutely nothing special about the fact it has ' around it.

The follow is exactly the same:

client.readProperty("192.168.1.41", { .........

So is this:

let myIP = "192.168.1.41";
client.readProperty(myIP, { .......

and this:

let myIP = '192.168.1.41';
client.readProperty(myIP, { .......

It has nothing to do with what quotes are used.

Do you want it to return two payloads? I see you have return msg at the end - that will be returning one message, and you also have node.send(msg) inside the client.readProperty callback which sets the payload and then sends it again.

If you don't want two messages, and only want the one with the payload, then don't do return msg at the end of the function.