Parse json data into function

Hi all!

I just want to parse Json data using Tasmota devices via MQTT into a function in order to obtain certain data that i need and put into a message via Telegram.

The main idea is to obtain via MQTT the actual hostname and firmware version of the Tasmota, so i can be aware whenever my Tasmotas are updated or not.

So, i have this so far...

I can correctly obtain the data i need...

Then inside my function i do this...but i only obtain the hostname, which is correctly because im calling that object.

image

But if want to join the two objects into my function that is where it fails...i don't know how to do that and i only obtain errors.

Thanks a lot!

With a switch node you can select "Has Key" (StatusNET) which will only pass it through if it exists.

Or in a different way, send the commands via http

which produces this output

flow

[{"id":"78f70367.0d9074","type":"inject","z":"f60f1f2f.6b207","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":180,"wires":[["da30c2f2.db772"]]},{"id":"da30c2f2.db772","type":"function","z":"f60f1f2f.6b207","name":"hosts","func":"const tasmotas = [\"10.0.0.26\",\"10.0.0.27\",\"10.0.0.24\"]\nconst status= \"/cm?cmnd=Status%200\"\nfor(let x=0;x<tasmotas.length;x++){\n    \n    node.send({url:\"http://\"+tasmotas[x]+status})\n    \n    \n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":180,"wires":[["f4d416e1.f85e98"]]},{"id":"2cf16dc2.081e4a","type":"debug","z":"f60f1f2f.6b207","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":200,"wires":[]},{"id":"f4d416e1.f85e98","type":"http request","z":"f60f1f2f.6b207","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":390,"y":180,"wires":[["b210a677.3baaf8"]]},{"id":"b210a677.3baaf8","type":"batch","z":"f60f1f2f.6b207","name":"","mode":"count","count":"3","overlap":0,"interval":10,"allowEmptySequence":false,"topics":[],"x":530,"y":180,"wires":[["5bfe3e09.1d8c88"]]},{"id":"5bfe3e09.1d8c88","type":"join","z":"f60f1f2f.6b207","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":650,"y":180,"wires":[["2cf16dc2.081e4a","96e34734.d82e1"]]},{"id":"96e34734.d82e1","type":"change","z":"f60f1f2f.6b207","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.{ \"name\":**.Hostname, \"ipAddress\":**.IPAddress, \"version\":**.Version  }","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":160,"wires":[["63f37354.f04534"]]},{"id":"63f37354.f04534","type":"debug","z":"f60f1f2f.6b207","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":990,"y":160,"wires":[]}]

Edit the "hosts" node with the ip's of your devices and update the batch node to the number of outputs you are expecting.

Cool!

Thanks a lot for that aproach!