NODE RED sortir le maxi / mini par mois d'un capteur de temperature par exemple

bonjour, je vous donne un exemple pour sortir les infos d’un capteur sur 2 tableaux, l’un vous donne les valeurs maxi pour chaque mois et l’autre les valeurs mini.

j’ai galérè à le faire ( mais je suis débutant) , alors si cela peut rendre service à d’autres.

le programme fonctionne, à vous de le modifier suivant votre utilité.

[{"id":"47f440de.3c3c18","type":"inject","z":"94f1d713.3529c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":540,"wires":[["c099f9dd.176ab8"]]},{"id":"c099f9dd.176ab8","type":"function","z":"94f1d713.3529c8","name":"remise a 0 des tableaux","func":"var theYear = {}\nvar theYear2 = {}\ntheYear = [\n    {\"mName\": \"Janvier\", \"loTemp\":100},\n    {\"mName\": \"Février\", \"loTemp\":100},\n    {\"mName\": \"Mars\", \"loTemp\":100},\n    {\"mName\": \"Avril\", \"loTemp\":100},\n    {\"mName\": \"Mai\", \"loTemp\":100},\n    {\"mName\": \"Juin\", \"loTemp\":100},\n    {\"mName\": \"Juillet\", \"loTemp\":100},\n    {\"mName\": \"Août\", \"loTemp\":100},\n    {\"mName\": \"Septembre\", \"loTemp\":100},\n    {\"mName\": \"Octobre\", \"loTemp\":100},\n    {\"mName\": \"Novembre\", \"loTemp\":100},\n    {\"mName\": \"Décembre\", \"loTemp\":100}\n    ]\ntheYear2 = [\n    {\"mName\": \"Janvier\", \"hiTemp\":0},\n    {\"mName\": \"Février\", \"hiTemp\":0},\n    {\"mName\": \"Mars\", \"hiTemp\":0},\n    {\"mName\": \"Avril\", \"hiTemp\":0},\n    {\"mName\": \"Mai\", \"hiTemp\":0},\n    {\"mName\": \"Juin\", \"hiTemp\":0},\n    {\"mName\": \"Juillet\", \"hiTemp\":0},\n    {\"mName\": \"Août\", \"hiTemp\":0},\n    {\"mName\": \"Septembre\", \"hiTemp\":0},\n    {\"mName\": \"Octobre\", \"hiTemp\":0},\n    {\"mName\": \"Novembre\", \"hiTemp\":0},\n    {\"mName\": \"Décembre\", \"hiTemp\":0}\n    ]\nflow.set(\"theYear\",theYear)\nflow.set(\"theYear2\",theYear2)\nmsg.payload = \"Réinitialisation de la température élevée pour tous les mois\"\nreturn msg;\n","outputs":1,"noerr":0,"x":390,"y":540,"wires":[["bdf00dd5.740c78"]]},{"id":"bdf00dd5.740c78","type":"trigger","z":"94f1d713.3529c8","op1":"","op2":" ","op1type":"pay","op2type":"str","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":580,"y":540,"wires":[["de2e06fd.fca67"]]},{"id":"de2e06fd.fca67","type":"ui_template","z":"94f1d713.3529c8","group":"3c182adf.1fc50e","name":"","order":1,"width":"12","height":"1","format":"<p style=\"font-size:25px; color:red !important;\">{{msg.payload}}</font>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":720,"y":540,"wires":[[]]},{"id":"964c7a87.4531","type":"debug","z":"94f1d713.3529c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":600,"wires":[]},{"id":"31479558.0f77aa","type":"function","z":"94f1d713.3529c8","name":"valeurs max","func":"var theYear2 = flow.get(\"theYear2\") || {};\n//node.warn(theYear)\n\n//get current month\nvar d = new Date();\nvar m = d.getMonth();\n//node.warn(m)\n//node.warn(theYear)\n//node.warn(theYear[m])\nvar mthHigh = theYear2[m].hiTemp  \n\nif (mthHigh < msg.payload) {\n    mthHigh = msg.payload\n    theYear2[m].hiTemp = mthHigh\n    flow.set(\"theYear2\",theYear2)\n    msg.payload = \"month: \" + (m+1) +\" val max: \"+mthHigh;\n//    msg.payload = \"new high for \" + theYear[m].mName +\" is \"+mthHigh;\n}\n\treturn msg;\n","outputs":1,"noerr":0,"x":470,"y":600,"wires":[["964c7a87.4531","5d05f4a.513f70c"]]},{"id":"5d05f4a.513f70c","type":"change","z":"94f1d713.3529c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"theYear2","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"payload[*]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":660,"wires":[["b046e9ea.12ae38","4c6eeca6.052084"]]},{"id":"4c6eeca6.052084","type":"debug","z":"94f1d713.3529c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":660,"wires":[]},{"id":"b046e9ea.12ae38","type":"ui_table","z":"94f1d713.3529c8","group":"3c182adf.1fc50e","name":"table","order":2,"width":"5","height":"7","columns":[],"outputs":0,"cts":false,"x":450,"y":700,"wires":[]},{"id":"73a474f6.a40bcc","type":"function","z":"94f1d713.3529c8","name":"valeurs min","func":"var theYear = flow.get(\"theYear\") || {};\n//node.warn(theYear)\n\n//get current month\nvar d = new Date();\nvar m = d.getMonth();\n//node.warn(m)\n//node.warn(theYear)\n//node.warn(theYear[m])\nvar mthHigh = theYear[m].loTemp  \n\nif (mthHigh > msg.payload) {\n    mthHigh = msg.payload\n    theYear[m].loTemp = mthHigh\n    flow.set(\"theYear\",theYear)\n    msg.payload = \"month: \" + (m+1) +\" val max: \"+mthHigh;\n//    msg.payload = \"new high for \" + theYear[m].mName +\" is \"+mthHigh;\n}\n\treturn msg;\n","outputs":1,"noerr":0,"x":450,"y":740,"wires":[["bee04a88.067ee","d2030fbb.416fa8"]]},{"id":"bee04a88.067ee","type":"debug","z":"94f1d713.3529c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":740,"wires":[]},{"id":"8b15242e.63941","type":"debug","z":"94f1d713.3529c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":780,"wires":[]},{"id":"d2030fbb.416fa8","type":"change","z":"94f1d713.3529c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"theYear","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"payload[*]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":780,"wires":[["fb62d44a.fb199","8b15242e.63941"]]},{"id":"fb62d44a.fb199","type":"ui_table","z":"94f1d713.3529c8","group":"3c182adf.1fc50e","name":"table","order":2,"width":"5","height":"7","columns":[],"outputs":0,"cts":false,"x":450,"y":820,"wires":[]},{"id":"898b19c5.8e00e","type":"inject","z":"94f1d713.3529c8","name":"","topic":"valeur","payload":"25","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":740,"wires":[["31479558.0f77aa","73a474f6.a40bcc"]]},{"id":"bb9514ec.98915","type":"inject","z":"94f1d713.3529c8","name":"","topic":"valeur","payload":"15","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":700,"wires":[["31479558.0f77aa","73a474f6.a40bcc"]]},{"id":"e68a4da8.c96b8","type":"inject","z":"94f1d713.3529c8","name":"","topic":"valeur","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":660,"wires":[["31479558.0f77aa","73a474f6.a40bcc"]]},{"id":"3c182adf.1fc50e","type":"ui_group","name":"Luftfeuchtigkeit","tab":"13fdc15a.f11f1f","order":4,"disp":false,"width":"12","collapse":false},{"id":"13fdc15a.f11f1f","type":"ui_tab","name":"Home - paul","icon":"home","order":1,"disabled":false,"hidden":false}]