Hi, I need some help working on a project since I am not so familiar with JavaScript.
What I need is the time between when the user on the emergency slider ON and OFF. The time also has to accumulate every time the status change.
The situation that will happen is like at 8:30 Emergency is on till 8:45 then Emergency on again at 9:20 then off at 9:25. The payload I need is 20.
I can get the time different use the below flow but not really sure on how to accumulate them
Thank you in advance
[{"id":"dd743d7cea6578f9","type":"function","z":"49e7cb4bbb6a8c74","name":"start counting stop","func":"var resume = flow.get(\"Resume\")||0\n\nif (msg.payload == \"STOP\"){\n var stop = new Date(); // current time\n flow.set(\"stopTime\", stop);\n} else {\n var running = new Date();\n resume = (running - flow.get(\"stopTime\"))/1000;\n}\n\nflow.set(\"Resume\", resume)\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":180,"wires":[[]]},{"id":"5eb25248627ebf72","type":"ui_switch","z":"49e7cb4bbb6a8c74","name":"","label":"Emergency","tooltip":"","group":"455218286d580613","order":3,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"status","topicType":"str","style":"","onvalue":"STOP","onvalueType":"str","onicon":"","oncolor":"","offvalue":"RUNNING","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":210,"y":180,"wires":[["dd743d7cea6578f9","2c116880aaeadb6e"]]},{"id":"2c116880aaeadb6e","type":"ui_text","z":"49e7cb4bbb6a8c74","group":"455218286d580613","order":4,"width":0,"height":0,"name":"","label":"STATUS","format":"{{msg.payload}}","layout":"row-center","className":"","x":400,"y":240,"wires":[]},{"id":"455218286d580613","type":"ui_group","name":"Button control","tab":"5e6283e6bfa1daa4","order":1,"disp":true,"width":"4","collapse":false,"className":""},{"id":"5e6283e6bfa1daa4","type":"ui_tab","name":"SIIT","icon":"dashboard","disabled":false,"hidden":false}]