How to trigger flow when context value change

Hello There,

I'm new to node red and I have a little problem whith my flow. I recover data from a S7- 1200 in order to create csv files. I was able to create this flow but there is still somethong missing. In order to work correctly my supervisor asked me to make this flow trigger when a bool value become true. Can somebody help me.

Best Regards !

Hi and welcome to the forum.

I am not sure why you are doing what you are doing the way you are doing it.

context variables are usually reserved for use internally by the flows.

Why can't you get what ever it is that is changing the context to be an input into the flow and get things happening that way?

(I don't know what a S7 - 1200 is)

This post in this thread may help you

Sorry I should have been more specific. I'm recovering data from a siemens automate. I created a flow that create a csv file by recovering the data from the device. According to my supervisor, the flow should trigger when one boolean value become true. I created a flow context value to use in a switch node. My question is How to trigger the flow when this value change.

I'm note sure I understand what this flow does. Can you explain it to me ?

Best Regards !

It does what you asked...

piJZP4h6xK

... triggers something when a flow context value is changed

That said...

by the sounds of it, you simply need an RBE (filter) node followed by a switch node to test when the incoming BOOL changes to true

PLC --> RBE --> SWITCH (test is true) --> do stuff

Please can you give us some more information:

Is this a project in an industrial setting - the supervisor is your boss , or is it an educational exercise?

Exactly what is this boolean value which should trigger a flow and how does it get into Node-red?

Sounds like you have made some progress. Please show us what your Node-red flow so far looks like.

Thank you

I'm working in a industrial setting, it's an internal project of my company.

Here is the code of my flow :

[{"id":"a3b1b0c573439f83","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.28","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":550,"y":40,"wires":[["9c49ccad81b32059"]]},{"id":"9c49ccad81b32059","type":"switch","z":"79fd906cf1fbcb03","name":"blockFlow is false?","property":"blockFlow","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":40,"wires":[["d6fed3aebccbda9d"]]},{"id":"d6fed3aebccbda9d","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":750,"y":100,"wires":},{"id":"7d7743a0e1ede1bb","type":"inject","z":"79fd906cf1fbcb03","name":"block","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":110,"y":80,"wires":[["2b7196943fe9e08e"]]},{"id":"1199dc42d750ac34","type":"inject","z":"79fd906cf1fbcb03","name":"unblock","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":110,"y":40,"wires":[["2b7196943fe9e08e"]]},{"id":"2b7196943fe9e08e","type":"change","z":"79fd906cf1fbcb03","name":"","rules":[{"t":"set","p":"blockFlow","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":60,"wires":[]},{"id":"541f352241334120","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"all","variable":"","diff":false,"name":"","x":100,"y":420,"wires":[["c8a35d05e145b0e5"]]},{"id":"c8a35d05e145b0e5","type":"switch","z":"79fd906cf1fbcb03","name":"Mesure_Write is fasle or true ?","property":"Mesure_Write","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":420,"wires":[["275f82d9f9e4c0de","a6d853488e6e7ca9"],["15f82642384cab00"]]},{"id":"fece6999e1cba138","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1050,"y":320,"wires":},{"id":"1e850f2e403c2fb8","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"single","variable":"FM_Write","diff":true,"name":"","x":240,"y":780,"wires":[["f12b4beddde95e1b"]]},{"id":"f12b4beddde95e1b","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":780,"wires":},{"id":"d4ac1ee9d34cc8f0","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":260,"y":860,"wires":[["c94976b5c21d64cf"]]},{"id":"c94976b5c21d64cf","type":"s7 out","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","variable":"FM_Write","name":"","x":480,"y":860,"wires":},{"id":"72c838f4f69d3aef","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":260,"y":920,"wires":[["c94976b5c21d64cf"]]},{"id":"8f62459ab7b90763","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":460,"wires":},{"id":"15f82642384cab00","type":"function","z":"79fd906cf1fbcb03","name":"","func":"msg.payload = null;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":620,"y":460,"wires":[["8f62459ab7b90763"]]},{"id":"275f82d9f9e4c0de","type":"function","z":"79fd906cf1fbcb03","name":"","func":"var run = flow.get("run");\nif (!run) \n return null;\n\nvar reset = flow.get("msgReset");\nif ( reset ) {\n msg.reset = true;\n flow.set("msgReset", 0);\n}\n\nmsg.columns = 'Date,Debit,Pression,Vitesse,Volume,Temps_ms,Debit_moy_hmi,Pression_moy_hmi,Vitesse_moy_hmi,Volume_moy_hmi';\n\nmsg.payload.Date = msg.payload.Date.toLocaleString("fr-FR");\nmsg.payload.Debit=Math.round(msg.payload.Debit10000)/10000;\nmsg.payload.Debit = msg.payload.Debit.toLocaleString("fr-FR");\nmsg.payload.Pression=Math.round(msg.payload.Pression10000)/10000;\nmsg.payload.Pression = msg.payload.Pression.toLocaleString("fr-FR");\nmsg.payload.Vitesse=Math.round(msg.payload.Vitesse10000)/10000;\nmsg.payload.Vitesse = msg.payload.Vitesse.toLocaleString("fr-FR");\nmsg.payload.Volume=Math.round(msg.payload.Volume10000)/10000;\nmsg.payload.Volume = msg.payload.Volume.toLocaleString("fr-FR");\nmsg.payload.Temps_ms = msg.payload.Temps_ms.toLocaleString("fr-FR");\nmsg.payload.Debit_moy_hmi=Math.round(msg.payload.Debit_moy_hmi10000)/10000;\nmsg.payload.Debit_moy_hmi = msg.payload.Debit_moy_hmi.toLocaleString("fr-FR");\nmsg.payload.Pression_moy_hmi=Math.round(msg.payload.Pression_moy_hmi10000)/10000;\nmsg.payload.Pression_moy_hmi = msg.payload.Pression_moy_hmi.toLocaleString("fr-FR");\nmsg.payload.Vitesse_moy_hmi=Math.round(msg.payload.Vitesse_moy_hmi10000)/10000;\nmsg.payload.Vitesse_moy_hmi = msg.payload.Vitesse_moy_hmi.toLocaleString("fr-FR");\nmsg.payload.Volume_moy_hmi=Math.round(msg.payload.Volume_moy_hmi10000)/10000;\nmsg.payload.Volume_moy_hmi = msg.payload.Volume_moy_hmi.toLocaleString("fr-FR");\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":680,"y":380,"wires":[["39f5daad7f6a213f"]]},{"id":"39f5daad7f6a213f","type":"csv","z":"79fd906cf1fbcb03","name":"Test","sep":";","hdrin":"","hdrout":"once","multi":"mult","ret":"\r\n","temp":"","skip":"0","strings":false,"include_empty_strings":"","include_null_values":"","x":830,"y":380,"wires":[["fece6999e1cba138","ec9842fea9bcb15e"]]},{"id":"134379e35816f308","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":640,"wires":[["b5143e0408217981"]]},{"id":"723c72304afd162e","type":"function","z":"79fd906cf1fbcb03","name":"","func":"var run = flow.get("run");\nif ( !run ) {\n run = new Date().toISOString('fr-FR');\n while ( run.includes('-') )\n run = run.replace('-', '');\n while ( run.includes(':') )\n run = run.replace(':', '');\n run = run.replace('T', '');\n run = "/home/selmoni/public/Mesures_Pulve/Mesures_VVB001" + run.substring(0,15) + '.csv';\n} else {\n run = false;\n }\nflow.set("run",run); \nflow.set("msgReset", true);\nmsg.payload = run;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":660,"y":600,"wires":[["d0d53f6f96679704"]]},{"id":"a036d1dcaa78546e","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":600,"wires":},{"id":"ec9842fea9bcb15e","type":"function","z":"79fd906cf1fbcb03","name":"","func":"msg.filename = flow.get("run");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":1020,"y":380,"wires":[["24aafcc3a783ed1d"]]},{"id":"24aafcc3a783ed1d","type":"file","z":"79fd906cf1fbcb03","name":"Mesures_VVB001_","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"false","encoding":"none","x":1230,"y":380,"wires":[]},{"id":"f8f4f8103ff174fd","type":"switch","z":"79fd906cf1fbcb03","name":"Mesure_Start is fasle or true ?","property":"Mesure_Start","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":150,"y":520,"wires":[,["addbcc2c55f22396"]]},{"id":"addbcc2c55f22396","type":"function","z":"79fd906cf1fbcb03","name":"","func":"msg.payload = "Mesures non lancés";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":380,"y":540,"wires":[["87af11f29f9e0034"]]},{"id":"87af11f29f9e0034","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":540,"wires":},{"id":"b5143e0408217981","type":"switch","z":"79fd906cf1fbcb03","name":"","property":"Mesure_Write","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":640,"wires":[["723c72304afd162e"]]},{"id":"d0d53f6f96679704","type":"trigger","z":"79fd906cf1fbcb03","name":"","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"-280","extend":false,"overrideDelay":false,"units":"ms","reset":"run","bytopic":"all","topic":"topic","outputs":1,"x":900,"y":600,"wires":[["a036d1dcaa78546e"]]},{"id":"30e7b58219494fec","type":"influxdb out","z":"79fd906cf1fbcb03","influxdb":"bc4ab5cb2a050021","name":"","measurement":"test","precision":"","retentionPolicy":"","database":"test","precisionV18FluxV20":"s","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":910,"y":260,"wires":},{"id":"a6d853488e6e7ca9","type":"function","z":"79fd906cf1fbcb03","name":"","func":"var run = flow.get("run");\nvar reset = flow.get("msgReset");\n\nif (!run) {\n return null;\n}\n \nif ( reset ) {\n msg.reset = true;\n flow.set("msgReset", 0);\n}\n\nmsg.payload.FM_Write = msg.payload.FM_Write.toString("fr-FR");\nmsg.payload.Date = msg.payload.Date.toLocaleString("fr-FR");\nmsg.payload.Temps_ms = msg.payload.Temps_ms.toLocaleString("fr-FR");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":680,"y":320,"wires":[["30e7b58219494fec"]]},{"id":"eefc44384a77e1f4","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"single","variable":"FM_Write","diff":false,"name":"","x":240,"y":980,"wires":[["f4203ce747524ab9"]]},{"id":"f4203ce747524ab9","type":"change","z":"79fd906cf1fbcb03","name":"","rules":[{"t":"set","p":"Mesure_Write","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":980,"wires":[]},{"id":"701517c3828f566e","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"single","variable":"Start_Mesure","diff":false,"name":"","x":250,"y":1040,"wires":[["a29550a7ef6da8df"]]},{"id":"a29550a7ef6da8df","type":"change","z":"79fd906cf1fbcb03","name":"","rules":[{"t":"set","p":"Mesure_Start","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":1040,"wires":[]},{"id":"fd48bf27a62cee6a","type":"s7 endpoint","transport":"iso-on-tcp","address":"192.168.200.3","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapter":"","busaddr":"2","cycletime":"500","timeout":"1500","name":"Selmoni_Pulve","vartable":[{"addr":"DB10,DTL272","name":"Date"},{"addr":"DB26,DWORD410","name":"Temps_ms"},{"addr":"DB26,REAL418","name":"Debit"},{"addr":"DB26,REAL414","name":"Pression"},{"addr":"DB26,REAL426","name":"Vitesse"},{"addr":"DB26,REAL422","name":"Volume"},{"addr":"DB26,X0.0","name":"Start_Mesure"},{"addr":"DB26,X0.5","name":"FM_Write"},{"addr":"DB26,REAL38","name":"Debit_moy_hmi"},{"addr":"DB26,REAL42","name":"Pression_moy_hmi"},{"addr":"DB26,REAL46","name":"Vitesse_moy_hmi"},{"addr":"DB26,REAL14","name":"Volume_moy_hmi"}]},{"id":"bc4ab5cb2a050021","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"test","name":"test","usetls":true,"tls":"d50d0c9f.31e858","influxdbVersion":"1.8-flux","url":" http://localhost:8086","rejectUnauthorized":false},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

And make sure there is nothing commercially sensitive in the exported flow!

Here is the correct json :

[{"id":"79fd906cf1fbcb03","type":"tab","label":"Selmoni Pulve Flow","disabled":false,"info":"","env":[]},{"id":"a3b1b0c573439f83","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.28","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":550,"y":40,"wires":[["9c49ccad81b32059"]]},{"id":"9c49ccad81b32059","type":"switch","z":"79fd906cf1fbcb03","name":"blockFlow is false?","property":"blockFlow","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":40,"wires":[["d6fed3aebccbda9d"]]},{"id":"d6fed3aebccbda9d","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":750,"y":100,"wires":[]},{"id":"7d7743a0e1ede1bb","type":"inject","z":"79fd906cf1fbcb03","name":"block","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":110,"y":80,"wires":[["2b7196943fe9e08e"]]},{"id":"1199dc42d750ac34","type":"inject","z":"79fd906cf1fbcb03","name":"unblock","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":110,"y":40,"wires":[["2b7196943fe9e08e"]]},{"id":"2b7196943fe9e08e","type":"change","z":"79fd906cf1fbcb03","name":"","rules":[{"t":"set","p":"blockFlow","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":60,"wires":[[]]},{"id":"541f352241334120","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"all","variable":"","diff":false,"name":"","x":100,"y":420,"wires":[["c8a35d05e145b0e5"]]},{"id":"c8a35d05e145b0e5","type":"switch","z":"79fd906cf1fbcb03","name":"Mesure_Write is fasle or true ?","property":"Mesure_Write","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":420,"wires":[["275f82d9f9e4c0de","a6d853488e6e7ca9"],["15f82642384cab00"]]},{"id":"fece6999e1cba138","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1050,"y":320,"wires":[]},{"id":"1e850f2e403c2fb8","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"single","variable":"FM_Write","diff":true,"name":"","x":240,"y":780,"wires":[["f12b4beddde95e1b"]]},{"id":"f12b4beddde95e1b","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":780,"wires":[]},{"id":"d4ac1ee9d34cc8f0","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":260,"y":860,"wires":[["c94976b5c21d64cf"]]},{"id":"c94976b5c21d64cf","type":"s7 out","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","variable":"FM_Write","name":"","x":480,"y":860,"wires":[]},{"id":"72c838f4f69d3aef","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":260,"y":920,"wires":[["c94976b5c21d64cf"]]},{"id":"8f62459ab7b90763","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":460,"wires":[]},{"id":"15f82642384cab00","type":"function","z":"79fd906cf1fbcb03","name":"","func":"msg.payload = null;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":460,"wires":[["8f62459ab7b90763"]]},{"id":"275f82d9f9e4c0de","type":"function","z":"79fd906cf1fbcb03","name":"","func":"var run = flow.get(\"run\");\nif (!run) \n    return null;\n\nvar reset = flow.get(\"msgReset\");\nif ( reset ) {\n    msg.reset = true;\n    flow.set(\"msgReset\", 0);\n}\n\nmsg.columns = 'Date,Debit,Pression,Vitesse,Volume,Temps_ms,Debit_moy_hmi,Pression_moy_hmi,Vitesse_moy_hmi,Volume_moy_hmi';\n\nmsg.payload.Date = msg.payload.Date.toLocaleString(\"fr-FR\");\nmsg.payload.Debit=Math.round(msg.payload.Debit*10000)/10000;\nmsg.payload.Debit = msg.payload.Debit.toLocaleString(\"fr-FR\");\nmsg.payload.Pression=Math.round(msg.payload.Pression*10000)/10000;\nmsg.payload.Pression = msg.payload.Pression.toLocaleString(\"fr-FR\");\nmsg.payload.Vitesse=Math.round(msg.payload.Vitesse*10000)/10000;\nmsg.payload.Vitesse = msg.payload.Vitesse.toLocaleString(\"fr-FR\");\nmsg.payload.Volume=Math.round(msg.payload.Volume*10000)/10000;\nmsg.payload.Volume = msg.payload.Volume.toLocaleString(\"fr-FR\");\nmsg.payload.Temps_ms = msg.payload.Temps_ms.toLocaleString(\"fr-FR\");\nmsg.payload.Debit_moy_hmi=Math.round(msg.payload.Debit_moy_hmi*10000)/10000;\nmsg.payload.Debit_moy_hmi = msg.payload.Debit_moy_hmi.toLocaleString(\"fr-FR\");\nmsg.payload.Pression_moy_hmi=Math.round(msg.payload.Pression_moy_hmi*10000)/10000;\nmsg.payload.Pression_moy_hmi = msg.payload.Pression_moy_hmi.toLocaleString(\"fr-FR\");\nmsg.payload.Vitesse_moy_hmi=Math.round(msg.payload.Vitesse_moy_hmi*10000)/10000;\nmsg.payload.Vitesse_moy_hmi = msg.payload.Vitesse_moy_hmi.toLocaleString(\"fr-FR\");\nmsg.payload.Volume_moy_hmi=Math.round(msg.payload.Volume_moy_hmi*10000)/10000;\nmsg.payload.Volume_moy_hmi = msg.payload.Volume_moy_hmi.toLocaleString(\"fr-FR\");\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":380,"wires":[["39f5daad7f6a213f"]]},{"id":"39f5daad7f6a213f","type":"csv","z":"79fd906cf1fbcb03","name":"Test","sep":";","hdrin":"","hdrout":"once","multi":"mult","ret":"\\r\\n","temp":"","skip":"0","strings":false,"include_empty_strings":"","include_null_values":"","x":830,"y":380,"wires":[["fece6999e1cba138","ec9842fea9bcb15e"]]},{"id":"134379e35816f308","type":"inject","z":"79fd906cf1fbcb03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":640,"wires":[["b5143e0408217981"]]},{"id":"723c72304afd162e","type":"function","z":"79fd906cf1fbcb03","name":"","func":"var run = flow.get(\"run\");\nif ( !run ) {\n  run = new Date().toISOString('fr-FR');\n  while ( run.includes('-') )\n    run = run.replace('-', '');\n  while ( run.includes(':') )\n    run = run.replace(':', '');\n  run = run.replace('T', '_');\n  run = \"/home/selmoni/public/Mesures_Pulve/Mesures_VVB001_\" + run.substring(0,15) + '.csv';\n} else {\n  run = false;\n }\nflow.set(\"run\",run); \nflow.set(\"msgReset\", true);\nmsg.payload = run;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":600,"wires":[["d0d53f6f96679704"]]},{"id":"a036d1dcaa78546e","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":600,"wires":[]},{"id":"ec9842fea9bcb15e","type":"function","z":"79fd906cf1fbcb03","name":"","func":"msg.filename = flow.get(\"run\");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":380,"wires":[["24aafcc3a783ed1d"]]},{"id":"24aafcc3a783ed1d","type":"file","z":"79fd906cf1fbcb03","name":"Mesures_VVB001_","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"false","encoding":"none","x":1230,"y":380,"wires":[[]]},{"id":"f8f4f8103ff174fd","type":"switch","z":"79fd906cf1fbcb03","name":"Mesure_Start is fasle or true ?","property":"Mesure_Start","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":150,"y":520,"wires":[[],["addbcc2c55f22396"]]},{"id":"addbcc2c55f22396","type":"function","z":"79fd906cf1fbcb03","name":"","func":"msg.payload = \"Mesures non lancés\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":540,"wires":[["87af11f29f9e0034"]]},{"id":"87af11f29f9e0034","type":"debug","z":"79fd906cf1fbcb03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":540,"wires":[]},{"id":"b5143e0408217981","type":"switch","z":"79fd906cf1fbcb03","name":"","property":"Mesure_Write","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":640,"wires":[["723c72304afd162e"]]},{"id":"d0d53f6f96679704","type":"trigger","z":"79fd906cf1fbcb03","name":"","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"-280","extend":false,"overrideDelay":false,"units":"ms","reset":"run","bytopic":"all","topic":"topic","outputs":1,"x":900,"y":600,"wires":[["a036d1dcaa78546e"]]},{"id":"30e7b58219494fec","type":"influxdb out","z":"79fd906cf1fbcb03","influxdb":"bc4ab5cb2a050021","name":"","measurement":"test","precision":"","retentionPolicy":"","database":"test","precisionV18FluxV20":"s","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":910,"y":260,"wires":[]},{"id":"a6d853488e6e7ca9","type":"function","z":"79fd906cf1fbcb03","name":"","func":"var run = flow.get(\"run\");\nvar reset = flow.get(\"msgReset\");\n\nif (!run) {\n    return null;\n}\n    \nif ( reset ) {\n   msg.reset = true;\n   flow.set(\"msgReset\", 0);\n}\n\nmsg.payload.FM_Write = msg.payload.FM_Write.toString(\"fr-FR\");\nmsg.payload.Date = msg.payload.Date.toLocaleString(\"fr-FR\");\nmsg.payload.Temps_ms = msg.payload.Temps_ms.toLocaleString(\"fr-FR\");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":320,"wires":[["30e7b58219494fec"]]},{"id":"eefc44384a77e1f4","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"single","variable":"FM_Write","diff":false,"name":"","x":240,"y":980,"wires":[["f4203ce747524ab9"]]},{"id":"f4203ce747524ab9","type":"change","z":"79fd906cf1fbcb03","name":"","rules":[{"t":"set","p":"Mesure_Write","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":980,"wires":[[]]},{"id":"701517c3828f566e","type":"s7 in","z":"79fd906cf1fbcb03","endpoint":"fd48bf27a62cee6a","mode":"single","variable":"Start_Mesure","diff":false,"name":"","x":250,"y":1040,"wires":[["a29550a7ef6da8df"]]},{"id":"a29550a7ef6da8df","type":"change","z":"79fd906cf1fbcb03","name":"","rules":[{"t":"set","p":"Mesure_Start","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":1040,"wires":[[]]},{"id":"fd48bf27a62cee6a","type":"s7 endpoint","transport":"iso-on-tcp","address":"192.168.200.3","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapter":"","busaddr":"2","cycletime":"500","timeout":"1500","name":"Selmoni_Pulve","vartable":[{"addr":"DB10,DTL272","name":"Date"},{"addr":"DB26,DWORD410","name":"Temps_ms"},{"addr":"DB26,REAL418","name":"Debit"},{"addr":"DB26,REAL414","name":"Pression"},{"addr":"DB26,REAL426","name":"Vitesse"},{"addr":"DB26,REAL422","name":"Volume"},{"addr":"DB26,X0.0","name":"Start_Mesure"},{"addr":"DB26,X0.5","name":"FM_Write"},{"addr":"DB26,REAL38","name":"Debit_moy_hmi"},{"addr":"DB26,REAL42","name":"Pression_moy_hmi"},{"addr":"DB26,REAL46","name":"Vitesse_moy_hmi"},{"addr":"DB26,REAL14","name":"Volume_moy_hmi"}]},{"id":"bc4ab5cb2a050021","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"test","name":"test","usetls":true,"tls":"d50d0c9f.31e858","influxdbVersion":"1.8-flux","url":" http://localhost:8086","rejectUnauthorized":false},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.