This is how i solve most variable configurations in my flows (although i guess your problem could be solved easier), but maybe it fits for you.
To try it you have to change the time in the config (keep the TZ in mind)
[{"id":"bd0ad736.9379c8","type":"inject","z":"c421dfeb.3e752","name":"config","topic":"","payload":"[{\"time\":\"1544\",\"name\":\"t1\",\"system\":\"xiaomi\",\"val\":5},{\"time\":\"1539\",\"name\":\"t2\",\"system\":\"xiaomi\",\"val\":15}]","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":"","x":312,"y":2833,"wires":[["a99e0ad7.3ebd08"]]},{"id":"a99e0ad7.3ebd08","type":"split","z":"c421dfeb.3e752","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":450,"y":2848,"wires":[["835ad930.18c278"]]},{"id":"835ad930.18c278","type":"change","z":"c421dfeb.3e752","name":"prep","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.time","tot":"msg"},{"t":"set","p":"priority","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":598,"y":2863,"wires":[["9dff040d.392b88"]]},{"id":"80b5655e.140048","type":"inject","z":"c421dfeb.3e752","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":437,"y":3013,"wires":[["e3aa05e8.6d6ce8"]]},{"id":"e3aa05e8.6d6ce8","type":"change","z":"c421dfeb.3e752","name":"prep","rules":[{"t":"set","p":"topic","pt":"msg","to":"$replace($substring($now(),11,5),\":\",\"\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":596,"y":2957,"wires":[["9dff040d.392b88"]]},{"id":"6ab6083d.058978","type":"debug","z":"c421dfeb.3e752","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":918,"y":2913,"wires":[]},{"id":"9dff040d.392b88","type":"function","z":"c421dfeb.3e752","name":"AJV8","func":"var countmsg = 2; //how many items to join?\n\nvar nodublicates = false; //only join if payload unequal existing payload\nvar limit; //only join if payloads are on both sides of the limit\nvar hysteresis; //hysteresis \nvar clearaftersend = false;//clear queue after sending\nvar sendinstantly = false;\nvar reverse = false; //reverse output array\nvar priomode = false;\nvar storagemode = true; \n//------------ different topic mode ------------------\nvar diftopics = false; //true: join only different topics; false: join only same topics\n\nvar inmsg = msg;\nvar outmsg = { \"topic\": inmsg.topic , \"payload\": \"\"};\nvar msgs = context.get(\"aggmsgs\")||{};\nvar topicmsgs = msgs[inmsg.topic]||[];\nvar lastval = context.get(\"lastval\");\nvar inprio = typeof inmsg.priority != \"undefined\" ? inmsg.priority: countmsg-1 ; //default prio is 1\n\nif (inmsg.topic === \"\")\n return null;\n\nif (typeof inmsg.reset != \"undefined\") {\n msgs = {};\n topicmsgs = [];\n lastval = undefined;\n context.set(\"aggmsgs\",msgs);\n context.set(\"lastval\",lastval);\n return null;\n}\nif (typeof inmsg.resettopic != \"undefined\") {\n topicmsgs = [];\n lastval = undefined;\n}\nif (typeof hysteresis !== 'undefined' && typeof lastval !== 'undefined') {\n if (Math.abs(inmsg.payload - lastval) <= hysteresis) {\n return null;\n }\n}\nif (typeof lastval !== 'undefined') {\n if (nodublicates && lastval == inmsg.payload)\n return null;\n if (typeof limit !== 'undefined' && countmsg == 2) {\n if (!((lastval <= limit && inmsg.payload >= limit) || (lastval >= limit && inmsg.payload <= limit))) \n return null;\n }\n} \n\nif (diftopics) {\n if (topicmsgs.length > 0) { //msg with same topic -> replace old msg\n topicmsgs.shift();\n }\n topicmsgs.push(inmsg);\n msgs[inmsg.topic] = topicmsgs; \n if (Object.keys(msgs).length > countmsg) {\n for (var tmsgs in msgs) {\n if (msgs.hasOwnProperty(tmsgs)) { \n delete msgs[tmsgs];\n break;\n }\n }\n }\n context.set(\"aggmsgs\",msgs);\n context.set(\"lastval\",inmsg.payload);\n if (Object.keys(msgs).length == countmsg) {\n var aout = {};\n outmsg.topic = \"\";\n for (var tmsgs in msgs) {\n if (msgs.hasOwnProperty(tmsgs)) {\n aout[tmsgs] = msgs[tmsgs][0];\n outmsg.topic += tmsgs + \"_\";\n }\n }\n if (clearaftersend) {\n context.set(\"aggmsgs\",undefined);\n context.set(\"lastval\",undefined);\n }\n outmsg.topic = outmsg.topic.substr(0,String(outmsg.topic).length-1);\n outmsg.payload = aout;\n if (reverse) {\n var revArr = outmsg.payload.map(a => Object.assign({}, a));\n revArr.reverse();\n outmsg.payload = revArr;\n }\n return outmsg;\n } else\n return null;\n} else {\n if (topicmsgs.length == countmsg && !storagemode){\n topicmsgs.shift();\n }\n if (storagemode) {\n topicmsgs[inprio] = inmsg;\n } else {\n topicmsgs.push(inmsg);\n }\n\n msgs[inmsg.topic] = topicmsgs;\n context.set(\"aggmsgs\",msgs);\n context.set(\"lastval\",inmsg.payload);\n \n if (storagemode) { //check send msg\n if (inprio < topicmsgs.length - 1) //only send on trigger msg => no priority\n return null;\n for (var i = 0; i < topicmsgs.length; i++) { //only send if storage is full\n if (topicmsgs[i] === undefined)\n return null;\n } \n }\n\n if (topicmsgs.length == countmsg || sendinstantly) {\n outmsg.payload = topicmsgs;\n if (clearaftersend) {\n msgs[inmsg.topic] = undefined;\n context.set(\"aggmsgs\",msgs);\n context.set(\"lastval\",undefined);\n }\n if (reverse) {\n var revArr = outmsg.payload.map(a => Object.assign({}, a));\n revArr.reverse();\n outmsg.payload = revArr;\n }\n return outmsg;\n }\n else\n return null;\n}\n\n","outputs":1,"noerr":0,"x":740,"y":2914,"wires":[["6ab6083d.058978"]]}]