Basically, If your 'interval-length' had the option to stop time counting, maybe my flow would work properly. See below my flow:
When the 'production' link sends the 'good' or 'bad' msg.topic, the 'start time' function block starts the running time count. When the block stops receiving this information, the 'interval-length' is reset, but starts a count again.
[{"id":"75f070de.d7a7a","type":"ui_text","z":"56fadb09.f90304","group":"93c3eb17.38ef38","order":10,"width":"11","height":"2","name":"","label":"Machine run time","format":"{{msg.payload}}","layout":"col-center","x":763.5,"y":186,"wires":[]},{"id":"8c93adf9.35dbe","type":"change","z":"56fadb09.f90304","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"runtimef","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":542.5,"y":186,"wires":[["75f070de.d7a7a"]]},{"id":"aab89673.bed658","type":"stoptimer","z":"56fadb09.f90304","duration":"5","units":"Second","payloadtype":"str","payloadval":"reset","name":"","x":334,"y":240,"wires":[[],["932e02d5.0818c","bb487422.480cf8"]]},{"id":"932e02d5.0818c","type":"function","z":"56fadb09.f90304","name":"Get Run Time","func":"hours = parseFloat(msg.payload.hours);\nmin = parseFloat(msg.payload.minutes);\nsec = parseFloat(msg.payload.seconds);\n\nvar time = context.get(\"time\") || [];\nnow = sec + (min*60) + (hours*360);\n\nif(msg.topic === \"good\" || msg.topic === \"bad\"){\nif(time.length === 0){\n time = 0;\n}\n\ntime = time + now;\n\nfunction format(number){\n\tif (number <= 9){\n\t\tnumber = \"0\" + number;\n }\nreturn number;\n\t}\n\nvar fhour = format(Math.round(time/3600));\nvar fmin = format(Math.floor((time%3600)/60));\nvar fseg = format((time%3600)%60);\n\n}\n\nif(msg.payload === 'reset'){\n time = 0;\n fhour = 0;\n fmin = 0;\n fseg = 0;\n msg.payload = 'stop';\n}\n\ncontext.set(\"time\",time);\nvar formated = fhour+\":\"+fmin+\":\"+fseg;\nmsg.runtime = time;\nmsg.runtimef = formated;\nreturn msg;","outputs":1,"noerr":0,"x":337,"y":185,"wires":[["8c93adf9.35dbe","aab89673.bed658"]]},{"id":"c6d2c1b3.17f","type":"interval-length","z":"56fadb09.f90304","format":"json","bytopic":true,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"","minimumunit":"msecs","maximumunit":"msecs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":true,"startup":false,"msgField":"payload","timestampField":"timestamp","repeatTimeout":false,"name":"","x":115,"y":186,"wires":[["932e02d5.0818c"],[]]},{"id":"f71f9977.fd2628","type":"change","z":"56fadb09.f90304","name":"","rules":[{"t":"change","p":"reset","pt":"msg","from":"reset","fromt":"str","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":114,"y":222,"wires":[["c6d2c1b3.17f"]]},{"id":"bb487422.480cf8","type":"change","z":"56fadb09.f90304","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":115,"y":258,"wires":[["f71f9977.fd2628"]]},{"id":"93c3eb17.38ef38","type":"ui_group","z":"","name":"Linha 1","tab":"bb3a6fe6.a0e13","disp":true,"width":"25","collapse":false},{"id":"bb3a6fe6.a0e13","type":"ui_tab","z":"","name":"OEE Online","icon":"dashboard","disabled":false,"hidden":false}]