Hello everyone, I have an array of elements. Each element is an array of elements.
[{"id":"4fc7389b1ee3ce61","type":"function","z":"22872ad18901ecfc","name":"find element","func":"\n// recupere le msg.payload : array : offsetBox label valeur unite description type nbByte facteur \n/*\n[\n [32, \"uint16\", 2, null, 100, \"ph:consigne\", null, \"phConsigne\"], //iD = 20\n [...]\n]\n*/\n\n//const trameMontanteParametresProtocole = flow.get(\"trameMontanteParametresProtocole\")\n//afficher le contenu du array qui contient \"phConsigne\"\n// il est Ă id: 20\n\nlet localised = msg.payload.indexOf(\"phConsigne\")\nmsg.localised = localised\nreturn msg\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":880,"wires":[["84a56d6cf338bc16"]]},{"id":"84a56d6cf338bc16","type":"debug","z":"22872ad18901ecfc","name":"localised","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1020,"y":880,"wires":[]},{"id":"4bd0b39beafd3d8f","type":"inject","z":"22872ad18901ecfc","name":"array","props":[{"p":"label","v":"phConsigne","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[[11,\"aa\"],[22,\"zz\"],[33,\"ee\"],[7.2,\"uint16\",2,null,100,\"phConsigne\"],[44,\"a\",\"rr\"],[55,\"tt\"],[66,\"yy\"],[77,\"uu\"]]","payloadType":"json","x":640,"y":880,"wires":[["4fc7389b1ee3ce61"]]}]
I would like to know the id of the element which contains a string for example "phConsigne"
(in the example it should tell me 3
).
I therefore use the method msg.payload.indexOf("phConsigne")
but it does not find it and indicates "not found" -1
Do you know what the fault is?
Thanks