After you do the count/sum of the different devices you can use the CSV node again to make into a csv and write the file with the File out node.
but the csv node doesnt play nice with the structure of the result in Steve's example.
Here's a similar flow of my attempt including making it into a csv
[{"id":"b864a7220ae9be76","type":"inject","z":"af25975e21b17ff4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":120,"y":540,"wires":[["4613383ac4e3ba67"]]},{"id":"30b5bb508d03c895","type":"function","z":"af25975e21b17ff4","name":"","func":"let result = [];\n\nmsg.ids.forEach(id => {\n let count = 0;\n msg.payload.forEach(el => {\n if (el.id == id) count += el.count;\n });\n result.push({ id: id, count: count });\n});\n\nmsg.payload = result;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":540,"wires":[["24b9035dd620e9e6","7711ca0ae58004ad"]]},{"id":"9914e33f060b0ba9","type":"debug","z":"af25975e21b17ff4","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":390,"y":480,"wires":[]},{"id":"b39d4fb3ac96d1a4","type":"csv","z":"af25975e21b17ff4","name":"","sep":";","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"id, count","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":470,"y":540,"wires":[["dafdf1ab940ed997","35d154baa0bebe97"]]},{"id":"dafdf1ab940ed997","type":"debug","z":"af25975e21b17ff4","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":480,"wires":[]},{"id":"4613383ac4e3ba67","type":"template","z":"af25975e21b17ff4","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"plain","template":"TRX1188-RED-LXL; 3\nTRX1188-WHT-LXL; 2\nTRX1188-WHT-LXL; 2\nTRX1252; 2\nTRX1252; 2\nTRX1362-L; 2","output":"str","x":280,"y":540,"wires":[["b39d4fb3ac96d1a4","9914e33f060b0ba9"]]},{"id":"35d154baa0bebe97","type":"change","z":"af25975e21b17ff4","name":"distinct ids","rules":[{"t":"set","p":"ids","pt":"msg","to":"$distinct(payload.id)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":540,"wires":[["30b5bb508d03c895"]]},{"id":"6f28bd6123e163ee","type":"debug","z":"af25975e21b17ff4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":540,"wires":[]},{"id":"24b9035dd620e9e6","type":"csv","z":"af25975e21b17ff4","name":"","sep":";","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"id, count","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":990,"y":540,"wires":[["6f28bd6123e163ee"]]},{"id":"7711ca0ae58004ad","type":"debug","z":"af25975e21b17ff4","name":"3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":480,"wires":[]},{"id":"6c3ce33983152af6","type":"comment","z":"af25975e21b17ff4","name":".. to file out node","info":"","x":1170,"y":480,"wires":[]}]