Notifications
Retirer tout

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


fe36ca0d4d6bdcc500dbd432c3c08731?s=80&d=mm&r=g
Posts: 509
Admin
Début du sujet
(@christophe)
Membre
Inscription: Il y a 6 ans

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""94f1d713.3529c8","name"0.1,"x"[["c099f9dd.176ab8"]]},{"id":"c099f9dd.176ab8","type""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"[["bdf00dd5.740c78"]]},{"id":"bdf00dd5.740c78","type""94f1d713.3529c8","op1"" ","op1type"[["de2e06fd.fca67"]]},{"id":"de2e06fd.fca67","type""94f1d713.3529c8","group":"3c182adf.1fc50e","name""<p style=\"font-size:25px; color:red !important;\">{{msg.payload}}</font>","storeOutMessages""964c7a87.4531","type""94f1d713.3529c8","name""31479558.0f77aa","type""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"[["964c7a87.4531","5d05f4a.513f70c"]]},{"id":"5d05f4a.513f70c","type""94f1d713.3529c8","name"[["b046e9ea.12ae38","4c6eeca6.052084"]]},{"id":"4c6eeca6.052084","type""94f1d713.3529c8","name""b046e9ea.12ae38","type""94f1d713.3529c8","group":"3c182adf.1fc50e","name""73a474f6.a40bcc","type""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"[["bee04a88.067ee","d2030fbb.416fa8"]]},{"id":"bee04a88.067ee","type""94f1d713.3529c8","name""8b15242e.63941","type""94f1d713.3529c8","name""d2030fbb.416fa8","type""94f1d713.3529c8","name"[["fb62d44a.fb199","8b15242e.63941"]]},{"id":"fb62d44a.fb199","type""94f1d713.3529c8","group":"3c182adf.1fc50e","name""898b19c5.8e00e","type""94f1d713.3529c8","name"0.1,"x"[["31479558.0f77aa","73a474f6.a40bcc"]]},{"id":"bb9514ec.98915","type""94f1d713.3529c8","name"0.1,"x"[["31479558.0f77aa","73a474f6.a40bcc"]]},{"id":"e68a4da8.c96b8","type""94f1d713.3529c8","name"0.1,"x"[["31479558.0f77aa","73a474f6.a40bcc"]]},{"id":"3c182adf.1fc50e","type""13fdc15a.f11f1f","order""13fdc15a.f11f1f","type""Home - paul","icon"false}]
Répondre
Étiquettes du sujet
Share:
Rejoignez nous!
Chercher sur le forum
Derniers tutoriels
Derniers messages postés sur le forum
Domotique et objets connectés à faire soi-même
Domotique et objets connectés à faire soi-même
Vous avez aimé ce tutoriel

Ne manquez plus les prochains projets

Recevez chaque semaine le récapitulatif des tutoriels et projets.

Vous pouvez vous désabonner à tout moment.