Or may be a bit more dynamic (object oriented) way
(flow contains node-red-node-random)
[{"id":"f6a645f4.6c51f8","type":"change","z":"1ea32064.47b71","name":"parse topic","rules":[{"t":"set","p":"targetUnit","pt":"msg","to":"$split(msg.topic, \"/\")[1]","tot":"jsonata"},{"t":"set","p":"measurement","pt":"msg","to":"$split(msg.topic, \"/\")[2]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":780,"wires":[["476acacd.dc40c4"]]},{"id":"6f482439.78c80c","type":"mqtt out","z":"1ea32064.47b71","name":"","topic":"","qos":"","retain":"","broker":"ec674c1c.f707b","x":730,"y":540,"wires":[]},{"id":"fef3ae43.cb5a3","type":"inject","z":"1ea32064.47b71","name":"","topic":"","payload":"","payloadType":"date","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":540,"wires":[["3af39d2a.512272"]]},{"id":"3af39d2a.512272","type":"random","z":"1ea32064.47b71","name":"","low":"0","high":"10","inte":"true","property":"payload","x":320,"y":540,"wires":[["3bc1afb.1e5ed5"]]},{"id":"3bc1afb.1e5ed5","type":"function","z":"1ea32064.47b71","name":"fake kW","func":"msg.topic=\"xyz/\"+msg.payload+\"/kW\"\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":540,"wires":[["8ef85a9e.28ca98"]]},{"id":"8ef85a9e.28ca98","type":"random","z":"1ea32064.47b71","name":"","low":"1","high":"10","inte":"true","property":"payload","x":600,"y":540,"wires":[["6f482439.78c80c"]]},{"id":"c06f5b2d.b22898","type":"mqtt in","z":"1ea32064.47b71","name":"","topic":"xyz/#","qos":"2","datatype":"auto","broker":"ec674c1c.f707b","x":120,"y":780,"wires":[["f6a645f4.6c51f8"]]},{"id":"91faf7d3.b92608","type":"debug","z":"1ea32064.47b71","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":920,"wires":[]},{"id":"476acacd.dc40c4","type":"function","z":"1ea32064.47b71","name":"store","func":"var units = global.get('units')||[] \nvar unit = units[msg.targetUnit] || {}\nvar measurement = unit[msg.measurement] || {[`${msg.measurement}`]:0}\nvar value = parseFloat(msg.payload)\nif(measurement != value){\n measurement = value\n unit[msg.measurement] = measurement\n units[msg.targetUnit] = unit\n units[msg.targetUnit].timestamp = new Date().getTime()\n global.set('units',units)\n msg.payload = msg.targetUnit\n msg.topic = \"unitUpdate\"\n return msg;\n}\n","outputs":1,"noerr":0,"x":430,"y":780,"wires":[["f1601565.a713f8"]]},{"id":"9a4ec3e.2a01c4","type":"mqtt out","z":"1ea32064.47b71","name":"","topic":"","qos":"","retain":"","broker":"ec674c1c.f707b","x":730,"y":600,"wires":[]},{"id":"b036345a.ac84c8","type":"inject","z":"1ea32064.47b71","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":600,"wires":[["9712ec5d.69bec"]]},{"id":"9712ec5d.69bec","type":"random","z":"1ea32064.47b71","name":"","low":"0","high":"10","inte":"true","property":"payload","x":320,"y":600,"wires":[["8b5d0f59.682cc"]]},{"id":"8b5d0f59.682cc","type":"function","z":"1ea32064.47b71","name":"fake ohm","func":"msg.topic=\"xyz/\"+msg.payload+\"/ohm\"\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":600,"wires":[["686da0e8.dc2e3"]]},{"id":"686da0e8.dc2e3","type":"random","z":"1ea32064.47b71","name":"","low":"1000","high":"10000","inte":"true","property":"payload","x":600,"y":600,"wires":[["9a4ec3e.2a01c4"]]},{"id":"f1601565.a713f8","type":"link out","z":"1ea32064.47b71","name":"unit-update","links":["7e91c635.3f6168"],"x":515,"y":780,"wires":[]},{"id":"7e91c635.3f6168","type":"link in","z":"1ea32064.47b71","name":"calculate","links":["f1601565.a713f8"],"x":200,"y":920,"wires":[["ab3c7808.3f4c38"]]},{"id":"ab3c7808.3f4c38","type":"switch","z":"1ea32064.47b71","name":"","property":"measurement","propertyType":"msg","rules":[{"t":"eq","v":"kW","vt":"str"},{"t":"eq","v":"ohm","vt":"str"},{"t":"eq","v":"temp","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":290,"y":920,"wires":[["807d846c.274a58"],["34ebfe03.b97bd2"],["ee3d6b24.fa4948"]]},{"id":"2834760c.a1600a","type":"mqtt out","z":"1ea32064.47b71","name":"","topic":"","qos":"","retain":"","broker":"ec674c1c.f707b","x":710,"y":660,"wires":[]},{"id":"edf0a5ba.fa5218","type":"inject","z":"1ea32064.47b71","name":"","topic":"","payload":"","payloadType":"date","repeat":"4","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":660,"wires":[["ba1354ff.f5b7c8"]]},{"id":"ba1354ff.f5b7c8","type":"random","z":"1ea32064.47b71","name":"","low":"0","high":"10","inte":"true","property":"payload","x":300,"y":660,"wires":[["6a2f127c.2f62ac"]]},{"id":"6a2f127c.2f62ac","type":"function","z":"1ea32064.47b71","name":"fake temp","func":"msg.topic=\"xyz/\"+msg.payload+\"/temp\"\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":660,"wires":[["19858194.59d89e"]]},{"id":"19858194.59d89e","type":"random","z":"1ea32064.47b71","name":"","low":"15","high":"35","inte":"false","property":"payload","x":580,"y":660,"wires":[["2834760c.a1600a"]]},{"id":"807d846c.274a58","type":"function","z":"1ea32064.47b71","name":"sum kW","func":"var units = global.get('units')\nvar sum = units.reduce((a, b) => a + (b.kW ? b.kW : 0), 0)\nmsg.payload = sum\nmsg.topic = 'sum of kW of all units'\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":880,"wires":[["91faf7d3.b92608"]]},{"id":"34ebfe03.b97bd2","type":"function","z":"1ea32064.47b71","name":"sum ohm","func":"var units = global.get('units')\nvar sum = units.reduce((a, b) => a + (b.ohm ? b.ohm : 0), 0)\nmsg.payload = sum\nmsg.topic = 'sum of ohm of all units'\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":920,"wires":[["91faf7d3.b92608"]]},{"id":"ee3d6b24.fa4948","type":"function","z":"1ea32064.47b71","name":"sum temp","func":"var units = global.get('units')\nvar sum = units.reduce((a, b) => a + (b.temp ? b.temp : 0), 0)\nmsg.payload = sum\nmsg.topic = 'sum of temp of all units'\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":960,"wires":[["91faf7d3.b92608"]]},{"id":"a73ef9e4.f4b828","type":"comment","z":"1ea32064.47b71","name":"fake measurements from 10 units","info":"","x":230,"y":500,"wires":[]},{"id":"5cd54264.19bc6c","type":"comment","z":"1ea32064.47b71","name":"store incoming measurements","info":"it creates the object to hold the data if it does not exist.\nit creates properties for object by the type of measurement\nit adds/adjusts timestamp of latest update\n\nit sends out the message as event indicating that some property of the unit has been changed\n","x":500,"y":740,"wires":[]},{"id":"b67da41e.884fc8","type":"comment","z":"1ea32064.47b71","name":"parse topic","info":"it parses out the unit id from where the message originates\n\nit parses out the measurement type\n","x":240,"y":740,"wires":[]},{"id":"29d73c2.544d2c4","type":"comment","z":"1ea32064.47b71","name":"switch by measurement type","info":"","x":220,"y":860,"wires":[]},{"id":"b1ecf37d.576b5","type":"comment","z":"1ea32064.47b71","name":"sum by type","info":"","x":450,"y":840,"wires":[]},{"id":"ec674c1c.f707b","type":"mqtt-broker","z":"","name":"nipi","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]