Hi there, beginner warning!
I have this flow working fine to extract the humidity value from a string:
[{"id":"879a195a.741c98","type":"inject","z":"5996dc31.f79034","name":"{\"status\":\"ok\",\"humidity\":\"53\"}","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"status\":\"ok\",\"humidity\":\"53\"}","payloadType":"str","x":460,"y":420,"wires":[["6e2e795d.9d47e8","715c958a.e0077c"]]},{"id":"715c958a.e0077c","type":"debug","z":"5996dc31.f79034","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":420,"wires":[]},{"id":"6e2e795d.9d47e8","type":"function","z":"5996dc31.f79034","name":"Extract humidity","func":"var IN = msg.payload.split(\"\\\"\");\nvar HUMID = parseInt(IN[7]);\nvar msg1 = {payload:HUMID};\nreturn [msg1];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":480,"wires":[["715c958a.e0077c"]]}]
But the node giving me the values is outputting an object...
msg.payload : Object
{ status: "ok", humidity: "53"
I have no clue how to modify this code:
var IN = msg.payload.split(""");
var HUMID = parseInt(IN[7]);
var msg1 = {payload:HUMID};
return [msg1];
from an object.
Now I get this error:
function : (error)
"TypeError: msg.payload.split is not a function"