hello everyone , i want ask if you have any idea about accumulates data in a variable
i have this flow to accumulate the downtime but the result is NaN
have a nice day ...
[{"id":"760419e7.c6a2d8","type":"inject","z":"f320c581.d9d3d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":190,"y":660,"wires":[["cd36a3a4.f762a"]]},{"id":"8bd3662.3529298","type":"inject","z":"f320c581.d9d3d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":190,"y":760,"wires":[["cd36a3a4.f762a"]]},{"id":"cd1e796d.159688","type":"debug","z":"f320c581.d9d3d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":720,"wires":[]},{"id":"bed8a9da.8bf5c8","type":"function","z":"f320c581.d9d3d8","name":"","func":"\n\nvar stopingT= flow.get(\"stopingT\") || 0;\nvar downtime1= flow.get(\"downtime1\") || 0;\nvar downtime= flow.get(\"downtime\") || 0;\n\nif (msg.payload) {\n // payload is true so save start time\n startTime = new Date()\n context.set(\"startTime\", startTime)\n msg = null // don't send a message\n} else {\n // payload is false so send start and end time\n startTime = context.get(\"startTime\") || 0\n if ( startTime === 0) {\n // no start time recorded so must be first time through so ignore it\n msg = null\n } else {\n var stopTime =new Date()\n var stoping = (stopTime - startTime)/60000\n stoping =Math.round(stoping * 100) / 100\n \n flow.set(\"downtime1\",stoping);\n // to store the data\n if(flow.get(\"downtime1\")!== 0)\n { var a\n \n a = flow.get(\"downtime\") + flow.get(\"downtime1\");\n \n flow.set(\"downtime\",a)\n a=0;\n \n \n }\n stoping = stoping.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})\n // stoping =parseFloat(\"stoping\")\n flow.set(\"stopingT\",stoping);\n msg.payload = startTime.toLocaleString(\"nl-BE\") +\"#\"+stopTime.toLocaleString(\"nl-BE\")+\"#\"+stoping \n // clear start time\n context.set(\"startTime\", 0)\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":700,"y":720,"wires":[["cd1e796d.159688"]]},{"id":"a18c495e.b03a18","type":"rbe","z":"f320c581.d9d3d8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":530,"y":720,"wires":[["bed8a9da.8bf5c8"]]},{"id":"cd36a3a4.f762a","type":"function","z":"f320c581.d9d3d8","name":"","func":"if(msg.payload === true)\nmsg.payload = false;\nelse \nmsg.payload = true;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":720,"wires":[["a18c495e.b03a18"]]}]