Hi all, I am trying to combine two streams of data. One feed has some of the attributes I need, and the other has the rest. Each stream has many nodes but most of the nodes can be singled out in each stream by their MAC address. I have attempted to combine the attributes of each one. I finally have both streams into one message payload separated further into payloads part 1 and part 2. I cant seem to combine like parts 1 and 2. Any suggestions?
Thanks again
My Flow
[{"id":"e21cc72a.85b078","type":"http request","z":"a61db8ad.cd7c68","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"https://10.254.1.19/api/v1/location","tls":"8b3830a0.cd07c","persist":false,"proxy":"","authType":"basic","x":150,"y":120,"wires":[["f58ab2a8.69306"]]},{"id":"f58ab2a8.69306","type":"change","z":"a61db8ad.cd7c68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Location_result","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":120,"wires":[["5c1752eb.aa83dc"]]},{"id":"3eddda3d.6710e6","type":"inject","z":"a61db8ad.cd7c68","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":320,"wires":[["3708805d.dcb4e","e21cc72a.85b078"]]},{"id":"5c1752eb.aa83dc","type":"split","z":"a61db8ad.cd7c68","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":490,"y":120,"wires":[["923aa877.bbff28"]]},{"id":"3708805d.dcb4e","type":"http request","z":"a61db8ad.cd7c68","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"https://10.254.1.19/api/v1/station","tls":"8b3830a0.cd07c","persist":false,"proxy":"","authType":"basic","x":150,"y":40,"wires":[["7dbb06e9.5ef5c8"]]},{"id":"923aa877.bbff28","type":"change","z":"a61db8ad.cd7c68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.msg","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":120,"wires":[["9a49840a.3b0428"]]},{"id":"7dbb06e9.5ef5c8","type":"change","z":"a61db8ad.cd7c68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Station_result","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":40,"wires":[["dc1eb92d.7e16f8"]]},{"id":"9a49840a.3b0428","type":"function","z":"a61db8ad.cd7c68","name":"","func":"var payload=msg.payload;\nmsg.payload = { \n \"mac_address\": payload.sta_eth_mac.addr,\n \"association\": payload.associated,\n \"x\": payload.sta_location_x,\n \"y\": payload.sta_location_y,\n \"alg\": payload.loc_algorithm,\n \"error_level\": payload.error_level,\n \"floor_id\": payload.floor_id }\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":180,"wires":[["f8659fb8.cd32c"]]},{"id":"dc1eb92d.7e16f8","type":"split","z":"a61db8ad.cd7c68","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":40,"wires":[["1cddd653.f9b0ea"]]},{"id":"f8659fb8.cd32c","type":"function","z":"a61db8ad.cd7c68","name":"","func":"var payload=msg.payload;\nmsg.topic = msg.payload.mac_address+\"_2\";\nreturn msg;","outputs":1,"noerr":0,"x":950,"y":120,"wires":[["991853c5.d60aa"]]},{"id":"1cddd653.f9b0ea","type":"change","z":"a61db8ad.cd7c68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.msg","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":40,"wires":[["209bbafa.5e6d76"]]},{"id":"991853c5.d60aa","type":"join","z":"a61db8ad.cd7c68","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"200","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1100,"y":280,"wires":[["3e3215c3.4a614a"]]},{"id":"209bbafa.5e6d76","type":"function","z":"a61db8ad.cd7c68","name":"","func":"var payload=msg.payload;\nmsg.payload = { \"Username\": payload.username,\n \"role\": payload.role,\n \"type\": payload.device_type,\n \"mac_address\": payload.sta_eth_mac.addr,\n \"ip_address\": payload.sta_ip_address.addr,\n \"access_point\": payload.ap_name,\n \"bssid\": payload.bssid.addr}\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":80,"wires":[["9af6712d.ae521"]]},{"id":"9af6712d.ae521","type":"function","z":"a61db8ad.cd7c68","name":"","func":"var payload=msg.payload;\nmsg.topic = msg.payload.mac_address+\"_1\";\nreturn msg;","outputs":1,"noerr":0,"x":1000,"y":40,"wires":[["991853c5.d60aa"]]},{"id":"3e3215c3.4a614a","type":"debug","z":"a61db8ad.cd7c68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1070,"y":360,"wires":[]},{"id":"8b3830a0.cd07c","type":"tls-config","z":"","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]
what returns
Was two long to past into code. so I attached.. and you have to see the beginning and end to see there is two payloads for each mac.. "mac"_1 and "mac"_2. Attached an image as well to see.
return.json (4.4 KB)
I'd love to get them into individual messages with the attributes from "mac"_1 and "mac"_2.
Also, if I am doing this totally wrong, just let me know. Learning as I go.