this is the welcome to the node-red message
Welcome to Node-RED
13 Jun 09:49:51 - [info] Node-RED version: v0.20.5
13 Jun 09:49:51 - [info] Node.js version: v10.15.3
13 Jun 09:49:51 - [info] Linux 4.15.0-48-generic x64 LE
13 Jun 09:49:52 - [info] Loading palette nodes
13 Jun 09:49:53 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
13 Jun 09:49:53 - [warn] rpi-gpio : Cannot find Pi RPi.GPIO python library
13 Jun 09:49:53 - [info] Settings file : /home/ubuntu/.node-red/settings.js
13 Jun 09:49:53 - [info] Context store : 'default' [module=memory]
13 Jun 09:49:53 - [info] User directory : /home/ubuntu/.node-red
13 Jun 09:49:53 - [warn] Projects disabled : editorTheme.projects.enabled=false
13 Jun 09:49:53 - [info] Flows file : /home/ubuntu/.node-red/flows_ubuntu23.json
13 Jun 09:49:53 - [info] Server now running at http://127.0.0.1:1880/
13 Jun 09:49:54 - [warn]
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
13 Jun 09:49:54 - [info] Starting flows
TypeError: Cannot read property 'id' of undefined
at remapSubflowNodes (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js:412:64)
at new Subflow (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js:85:9)
at Object.createSubflow [as create] (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js:435:12)
at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:187:51)
at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:329:33)
at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:483:13)
at Scheduler._drain (/usr/lib/node_modules/node-red/node_modules/when/lib/Scheduler.js:62:19)
13 Jun 09:49:55 - [info] Started flows
13 Jun 09:49:55 - [info] [mqtt-broker:8bd04cb3.99d51] Connected to broker: mqtt://10.23.14.19:1883
13 Jun 09:56:52 - [error] [function:Material] TypeError: this.subflowInstanceNodes[sfId].getNode is not a function
That error shows up now everytime i want to create a context/flow/global variable.
As what did I change? Nothing. THAT's what confused me. It's running just fine until yesterday.
I was just checking my program because it's been one week running. This is the program:
[{"id":"338389b4.ee7de6","type":"subflow","name":"I/O Data","info":"","category":"EWS","in":[{"x":60,"y":240,"wires":[{"id":"f80327cb.61ae68"}]}],"out":[{"x":440,"y":60,"wires":[{"id":"edaaf21.b59571","port":0}]},{"x":1300,"y":80,"wires":[{"id":"c8165c6d.03c58","port":0}]},{"x":1300,"y":120,"wires":[{"id":"3093c42c.dcfffc","port":0}]},{"x":1160,"y":180,"wires":[{"id":"10f08c43.368dc4","port":0}]},{"x":1280,"y":240,"wires":[{"id":"4150f35b.b0d5fc","port":0},{"id":"4fbdf7d6.a53d88","port":0},{"id":"5369cbc1.55fdd4","port":0},{"id":"f1da942f.fb70c8","port":0}]}],"env":[]},{"id":"e2dd5a4e.4e6598","type":"function","z":"338389b4.ee7de6","name":"Increment","func":"var data = msg.payload;\nvar status = data.status;\n\nif (status==\"R\"){\n msg.increment = 1;\n}\nelse if (status==\"F\"){\n msg.reset=true;\n}\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":140,"wires":[["767cd536.23e32c"]]},{"id":"767cd536.23e32c","type":"counter","z":"338389b4.ee7de6","name":"","init":"0","step":"1","lower":"-1","upper":null,"mode":"increment","outputs":"1","x":760,"y":140,"wires":[["3949835c.97434c","e0ac9e5d.79665"]]},{"id":"3949835c.97434c","type":"delay","z":"338389b4.ee7de6","name":"d01","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":750,"y":80,"wires":[["767cd536.23e32c"]]},{"id":"7f693540.e1b87c","type":"function","z":"338389b4.ee7de6","name":"Timer","func":"var mesin = msg.payload.mesin;\nvar ws = msg.payload.kodews;\nvar status = msg.payload.status;\n\nvar set_status = flow.set(\"status_\"+ws+\"_\"+mesin,status);\nif (status==\"W\"){\n msg.payload=0;\n}\nelse {\n msg.payload=msg.payload;\n}\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":140,"wires":[["82c09237.f0847"]]},{"id":"82c09237.f0847","type":"switch","z":"338389b4.ee7de6","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":140,"wires":[["e2dd5a4e.4e6598"],[]]},{"id":"f80327cb.61ae68","type":"switch","z":"338389b4.ee7de6","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":240,"wires":[["fc1efc3d.b820b","525b02c5.b19b1c","7f693540.e1b87c","edaaf21.b59571"],[]]},{"id":"10f08c43.368dc4","type":"function","z":"338389b4.ee7de6","name":"InfluxDB","func":"var mesin = msg.payload.mesin;\nvar ws = msg.payload.kodews;\nvar breakdown = msg.payload.breakdown;\nvar report = msg.report;\nvar work = msg.work;\n\nif ((report>0)&&(work===0)){\n msg.measurement = mesin;\n msg.payload=[{\n status:1,\n als_stop:breakdown,\n report:report,\n durasi:work\n },\n {\n kd_status:ws\n }]\n}\nelse if ((report>0)&&(work>0)){\n msg.measurement = mesin;\n msg.payload=[{\n status:2,\n als_stop:breakdown,\n report:report,\n durasi:work\n },\n {\n kd_status:ws\n }]\n}\nelse{\n msg.measurement = mesin;\n msg.payload=[{\n status:3,\n als_stop:0,\n report:0,\n durasi:0\n },\n {\n kd_status:ws\n }]\n}\nreturn msg;","outputs":1,"noerr":0,"x":1060,"y":180,"wires":[[]]},{"id":"c8165c6d.03c58","type":"function","z":"338389b4.ee7de6","name":"Report","func":"var report = msg.report;\nvar mesin = (msg.payload.mesin).toLowerCase();\nvar ws = (msg.payload.kodews).toLowerCase();\n\nmsg.topic = ws+\"/\"+mesin+\"_report\";\nmsg.payload = report;\n\nreturn msg;","outputs":1,"noerr":0,"x":1210,"y":80,"wires":[[]]},{"id":"3093c42c.dcfffc","type":"function","z":"338389b4.ee7de6","name":"Work","func":"var work = msg.work;\nvar mesin = (msg.payload.mesin).toLowerCase();\nvar ws = (msg.payload.kodews).toLowerCase();\n\nmsg.topic = ws+\"/\"+mesin+\"_work\";\nmsg.payload = work;\n\nreturn msg;","outputs":1,"noerr":0,"x":1210,"y":120,"wires":[[]]},{"id":"e0ac9e5d.79665","type":"function","z":"338389b4.ee7de6","name":"Timer","func":"var mesin = msg.payload.mesin;\nvar ws = msg.payload.kodews;\nvar status = flow.get(\"status_\"+ws+\"_\"+mesin);\n\nif (status==\"R\"){\n var timer1 = flow.set(\"report_\"+ws+\"_\"+mesin,msg.count);\n msg.report = msg.count;\n msg.work = 0;\n}\nelse if (status==\"W\"){\n var timer2 = flow.get(\"report_\"+ws+\"_\"+mesin);\n msg.report = timer2;\n msg.work = msg.count - timer2;\n}\nelse {\n msg.report = 0;\n msg.work = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":910,"y":140,"wires":[["cc328886.692dc8","10f08c43.368dc4"]]},{"id":"cc328886.692dc8","type":"function","z":"338389b4.ee7de6","name":"Show Timer","func":"var r_second = String(Math.floor(msg.report%60)).padStart(2,\"0\");\nvar r_minute = String(Math.floor((msg.report/60)%60)).padStart(2,\"0\");\nvar r_hour = String(Math.floor(msg.report/(60*60))).padStart(2,\"0\");\nmsg.report = r_hour+\":\"+r_minute+\":\"+r_second;\n \nvar w_second = String(Math.floor(msg.work%60)).padStart(2,\"0\");\nvar w_minute = String(Math.floor((msg.work/60)%60)).padStart(2,\"0\");\nvar w_hour = String(Math.floor(msg.work/(60*60))).padStart(2,\"0\");\nmsg.work = w_hour+\":\"+w_minute+\":\"+w_second;\n\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":100,"wires":[["c8165c6d.03c58","3093c42c.dcfffc"]]},{"id":"f1da942f.fb70c8","type":"delay","z":"338389b4.ee7de6","name":"d02","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1150,"y":440,"wires":[[]]},{"id":"dbf723f1.a044f","type":"interval-length","z":"338389b4.ee7de6","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"","minimumunit":"msecs","maximumunit":"msecs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":true,"startup":false,"msgField":"timer","timestampField":"timestamp","repeatTimeout":false,"name":"interval","x":760,"y":280,"wires":[["4fbdf7d6.a53d88"],[]]},{"id":"6311c293.15af0c","type":"change","z":"338389b4.ee7de6","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":260,"wires":[["dbf723f1.a044f"]]},{"id":"3782f91f.910526","type":"interval-length","z":"338389b4.ee7de6","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"","minimumunit":"msecs","maximumunit":"msecs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":true,"startup":false,"msgField":"timer","timestampField":"timestamp","repeatTimeout":false,"name":"interval","x":760,"y":360,"wires":[["5369cbc1.55fdd4"],[]]},{"id":"75818a8.8ebab74","type":"change","z":"338389b4.ee7de6","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":340,"wires":[["3782f91f.910526"]]},{"id":"525b02c5.b19b1c","type":"function","z":"338389b4.ee7de6","name":"MySQL","func":"var data = msg.payload;\nvar kd_stp = msg.payload.status;\n\nif (kd_stp==\"R\"){\n var msg01={payload:data};\n}\nelse if (kd_stp==\"W\"){\n var msg02={payload:data};\n}\nelse if (kd_stp==\"F\"){\n var msg03={payload:data};\n}\nreturn [msg01,msg02,msg03];","outputs":3,"noerr":0,"x":360,"y":340,"wires":[["ce299f36.8735e"],["564a78c7.bed468"],["f6872beb.0a5138"]]},{"id":"ce299f36.8735e","type":"link out","z":"338389b4.ee7de6","name":"t01","links":["e066d881.775108","4d2cee26.b4ef2","a38c52a7.c1e5a","9feb21bd.9ffef"],"x":475,"y":300,"wires":[]},{"id":"564a78c7.bed468","type":"link out","z":"338389b4.ee7de6","name":"t02","links":["66d2d37d.3024ec","e066d881.775108","9feb21bd.9ffef"],"x":475,"y":340,"wires":[]},{"id":"f6872beb.0a5138","type":"link out","z":"338389b4.ee7de6","name":"t03","links":["38ff1c5d.04c9d4","66d2d37d.3024ec","2a9c3990.882976","a38c52a7.c1e5a","c75615f8.b8ba18"],"x":475,"y":380,"wires":[]},{"id":"e066d881.775108","type":"link in","z":"338389b4.ee7de6","name":"t01","links":["ce299f36.8735e","564a78c7.bed468"],"x":655,"y":300,"wires":[["dbf723f1.a044f"]]},{"id":"38ff1c5d.04c9d4","type":"link in","z":"338389b4.ee7de6","name":"t03","links":["f6872beb.0a5138"],"x":535,"y":260,"wires":[["6311c293.15af0c"]]},{"id":"66d2d37d.3024ec","type":"link in","z":"338389b4.ee7de6","name":"t02","links":["564a78c7.bed468","f6872beb.0a5138"],"x":655,"y":380,"wires":[["3782f91f.910526"]]},{"id":"4d2cee26.b4ef2","type":"link in","z":"338389b4.ee7de6","name":"t01","links":["ce299f36.8735e"],"x":535,"y":340,"wires":[["75818a8.8ebab74"]]},{"id":"bef7ed2a.54934","type":"interval-length","z":"338389b4.ee7de6","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"","minimumunit":"msecs","maximumunit":"msecs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":true,"startup":false,"msgField":"timer","timestampField":"timestamp","repeatTimeout":false,"name":"interval","x":880,"y":440,"wires":[["39f52fe7.413db"],[]]},{"id":"4ec97f7a.d541e","type":"change","z":"338389b4.ee7de6","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":420,"wires":[["bef7ed2a.54934"]]},{"id":"a38c52a7.c1e5a","type":"link in","z":"338389b4.ee7de6","name":"t01","links":["ce299f36.8735e","f6872beb.0a5138"],"x":775,"y":460,"wires":[["bef7ed2a.54934"]]},{"id":"2a9c3990.882976","type":"link in","z":"338389b4.ee7de6","name":"t03","links":["f6872beb.0a5138"],"x":535,"y":420,"wires":[["99a11821.c8cdf8"]]},{"id":"99a11821.c8cdf8","type":"delay","z":"338389b4.ee7de6","name":"d03","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":420,"wires":[["4ec97f7a.d541e"]]},{"id":"5369cbc1.55fdd4","type":"function","z":"338389b4.ee7de6","name":"MySQL","func":"var key = msg.payload.key;\n\nvar date = String(new Date(msg.timestamp).getDate()).padStart(2,\"0\");\nvar month = String(new Date(msg.timestamp).getMonth()+1).padStart(2,\"0\");\nvar year = String(new Date(msg.timestamp).getFullYear());\nvar hour = String(new Date(msg.timestamp).getHours()).padStart(2,\"0\");\nvar minute = String(new Date(msg.timestamp).getMinutes()).padStart(2,\"0\");\nvar second = String(new Date(msg.timestamp).getSeconds()).padStart(2,\"0\");\nvar w_timestamp = year+\"-\"+month+\"-\"+date+\" \"+hour+\":\"+minute+\":\"+second;\n\nvar timer = msg.timer;\nvar w_second = String(Math.floor((timer/1000)%60)).padStart(2,\"0\");\nvar w_minute = String(Math.floor((timer/(1000*60))%60)).padStart(2,\"0\");\nvar w_hour = String(Math.floor(timer/(1000*60*60))).padStart(2,\"0\");\nvar w_timer = w_hour+\":\"+w_minute+\":\"+w_second;\n\nmsg.topic = \"UPDATE report_v0 SET ymd_work ='\"+w_timestamp+\"', time_work = '\"+w_timer+\"' WHERE day_id = '\"+key+\"'\";\n\nreturn msg;","outputs":1,"noerr":0,"x":900,"y":360,"wires":[[]]},{"id":"39f52fe7.413db","type":"function","z":"338389b4.ee7de6","name":"MySQL","func":"var key = msg.payload.key;\n\nvar date = String(new Date().getDate()).padStart(2,\"0\");\nvar month = String(new Date().getMonth()+1).padStart(2,\"0\");\nvar year = String(new Date().getFullYear());\nvar hour = String(new Date().getHours()).padStart(2,\"0\");\nvar minute = String(new Date().getMinutes()).padStart(2,\"0\");\nvar second = String(new Date().getSeconds()).padStart(2,\"0\");\nvar f_timestamp = year+\"-\"+month+\"-\"+date+\" \"+hour+\":\"+minute+\":\"+second;\n\nvar timer = msg.timer;\nvar f_second = String(Math.floor((timer/1000)%60)).padStart(2,\"0\");\nvar f_minute = String(Math.floor((timer/(1000*60))%60)).padStart(2,\"0\");\nvar f_hour = String(Math.floor((timer/(1000*60*60))%24)).padStart(2,\"0\");\nvar f_timer = f_hour+\":\"+f_minute+\":\"+f_second;\n\nmsg.topic = \"UPDATE report_v0 SET ymd_finish ='\"+f_timestamp+\"', time_finish = '\"+f_timer+\"' WHERE day_id = '\"+key+\"'\";\n\nreturn msg;","outputs":1,"noerr":0,"x":1020,"y":440,"wires":[["f1da942f.fb70c8"]]},{"id":"4fbdf7d6.a53d88","type":"function","z":"338389b4.ee7de6","name":"MySQL","func":"var key = msg.payload.key;\n\nvar date = String(new Date(msg.timestamp).getDate()).padStart(2,\"0\");\nvar month = String(new Date(msg.timestamp).getMonth()+1).padStart(2,\"0\");\nvar year = String(new Date(msg.timestamp).getFullYear());\nvar hour = String(new Date(msg.timestamp).getHours()).padStart(2,\"0\");\nvar minute = String(new Date(msg.timestamp).getMinutes()).padStart(2,\"0\");\nvar second = String(new Date(msg.timestamp).getSeconds()).padStart(2,\"0\");\nvar r_timestamp = year+\"-\"+month+\"-\"+date+\" \"+hour+\":\"+minute+\":\"+second;\n\nvar timer = msg.timer;\nvar r_second = String(Math.floor((timer/1000)%60)).padStart(2,\"0\");\nvar r_minute = String(Math.floor((timer/(1000*60))%60)).padStart(2,\"0\");\nvar r_hour = String(Math.floor(timer/(1000*60*60))).padStart(2,\"0\");\nvar r_timer = r_hour+\":\"+r_minute+\":\"+r_second;\n\nmsg.topic = \"UPDATE report_v0 SET ymd_report ='\"+r_timestamp+\"', time_report = '\"+r_timer+\"' WHERE day_id = '\"+key+\"'\";\n\nreturn msg;","outputs":1,"noerr":0,"x":900,"y":280,"wires":[[]]},{"id":"4150f35b.b0d5fc","type":"function","z":"338389b4.ee7de6","name":"Primary Key","func":"var mesin = msg.payload.mesin;\nvar breakdown = msg.payload.breakdown;\nvar flw = msg.payload.flow;\nvar key = msg.payload.key;\n\nmsg.topic = \"INSERT INTO report_v0 (day_id,mcn_id,stop_id,flow_id) VALUES ('\"+key+\"','\"+mesin+\"-\"+flw+\"','\"+breakdown+\"','\"+flw+\"');\"\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":200,"wires":[[]]},{"id":"fc1efc3d.b820b","type":"switch","z":"338389b4.ee7de6","name":"","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"R","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":200,"wires":[["4150f35b.b0d5fc"],[]]},{"id":"a7488ed5.fcf97","type":"function","z":"338389b4.ee7de6","name":"Reset Variable","func":"var mesin = msg.payload.mesin;\nvar ws = msg.payload.kodews;\nvar status = flow.set(\"status_\"+ws+\"_\"+mesin,undefined);\nvar report = flow.set(\"report_\"+ws+\"_\"+mesin,undefined);\n\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":520,"wires":[[]]},{"id":"c75615f8.b8ba18","type":"link in","z":"338389b4.ee7de6","name":"t04","links":["f6872beb.0a5138"],"x":535,"y":520,"wires":[["a7488ed5.fcf97"]]},{"id":"edaaf21.b59571","type":"function","z":"338389b4.ee7de6","name":"Buzzer","func":"var mesin = (msg.payload.mesin).toLowerCase();\nvar ws = (msg.payload.kodews).toLowerCase();\nvar breakdown = msg.payload.breakdown;\nvar status = msg.payload.status;\n\nif (status==\"R\"){\n if (breakdown==61){\n msg.topic = \"bb/buzzer_\"+mesin;\n msg.payload = 1;\n }\n else{\n msg.topic = ws+\"/buzzer_\"+mesin;\n msg.payload = 1;\n }\n}\nelse if (status==\"W\"){\n if (breakdown==61){\n msg.topic = \"bb/buzzer_\"+mesin;\n msg.payload = 2;\n }\n else{\n msg.topic = ws+\"/buzzer_\"+mesin;\n msg.payload = 2;\n }\n}\nelse if (status==\"F\"){\n if (breakdown==61){\n msg.topic = \"bb/buzzer_\"+mesin;\n msg.payload = 3;\n }\n else{\n msg.topic = ws+\"/buzzer_\"+mesin;\n msg.payload = 3;\n }\n}\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":60,"wires":[[]]},{"id":"3559585a.5ecd78","type":"inject","z":"89d730c1.41912","name":"","topic":"","payload":"R","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":100,"wires":[["ce956f94.1ec08"]]},{"id":"ce956f94.1ec08","type":"function","z":"89d730c1.41912","name":"","func":"var data = msg.payload;\n\nmsg.payload={\n mesin:\"BF12412\",\n status:data,\n kodews:\"MA\",\n kodearea:\"BF2\",\n breakdown:\"61\",\n plant:\"GM1\"\n};\nreturn msg;","outputs":1,"noerr":0,"x":230,"y":140,"wires":[["3a92d983.829456"]]},{"id":"3a92d983.829456","type":"function","z":"89d730c1.41912","name":"BF12412","func":"var mesin = msg.payload.mesin;\nvar status = msg.payload.status;\nvar breakdown = Number(msg.payload.breakdown);\nvar ws = msg.payload.kodews;\n\nif (mesin==\"BF12412\"){\n msg.payload={\n mesin:mesin,\n status:status,\n kodews:ws,\n flow:\"F\",\n breakdown:breakdown\n };\n}\nelse {\n msg.payload=0;\n}\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":140,"wires":[["e6419cee.5f9b4"]]},{"id":"e6419cee.5f9b4","type":"switch","z":"89d730c1.41912","name":"Check Mesin","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":140,"wires":[["fd5b6123.f5323"],[]]},{"id":"e29523fc.bee0c","type":"inject","z":"89d730c1.41912","name":"","topic":"","payload":"W","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":140,"wires":[["ce956f94.1ec08"]]},{"id":"486df0a1.b13bb","type":"inject","z":"89d730c1.41912","name":"","topic":"","payload":"F","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":180,"wires":[["ce956f94.1ec08"]]},{"id":"fd5b6123.f5323","type":"function","z":"89d730c1.41912","name":"Material","func":"var status = msg.payload.status;\nvar mesin = msg.payload.mesin;\nvar ws = msg.payload.kodews;\nvar breakdown = msg.payload.breakdown;\nvar flw = msg.payload.flow;\nvar cek = flow.get(\"last_key_\"+ws+\"_\"+mesin);\n\nif ((breakdown>60)&&(breakdown<70)){\n if (status==\"R\"){\n if (cek===undefined){\n var year = new Date().getFullYear();\n var date = String(new Date().getDate()).padStart(2,\"0\");\n var month = String(new Date().getMonth()+1).padStart(2,\"0\");\n var hour = String(new Date().getHours()).padStart(2,\"0\");\n var minute = String(new Date().getMinutes()).padStart(2,\"0\");\n var second = String(new Date().getSeconds()).padStart(2,\"0\");\n\n msg.payload.key = year+month+date+\"-\"+hour+minute+second+\"-\"+mesin+\"-\"+flw;\n var key = flow.set(\"last_key_\"+ws+\"_\"+mesin,year+month+date+\"-\"+hour+minute+second+\"-\"+mesin+\"-\"+flw);\n msg.payload = msg.payload;\n }\n else {\n msg.payload = 0;\n }\n }\n else if (status==\"W\"){\n if (cek!==undefined){\n msg.payload.key = flow.get(\"last_key_\"+ws+\"_\"+mesin);\n msg.payload=msg.payload;\n }\n else {\n msg.payload=0;\n }\n }\n else if (status==\"F\"){\n if (cek!==undefined){\n msg.payload.key = flow.get(\"last_key_\"+ws+\"_\"+mesin);\n msg.payload=msg.payload;\n var timeout = setTimeout(function(){\n msg.payload = flow.set(\"last_key_\"+ws+\"_\"+mesin,undefined);\n },1000)\n }\n else {\n msg.payload=0;\n }\n }\n}\nelse{\n msg.payload=0;\n}\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":140,"wires":[["4c21dad5.7bbd04"]]},{"id":"4c21dad5.7bbd04","type":"subflow:338389b4.ee7de6","z":"89d730c1.41912","name":"","env":[],"x":800,"y":140,"wires":[["c9f1620f.3eab3"],["524d475.70352b8"],["f6ef04cc.bc5028"],["72f1220f.35076c"],["a85a72e1.645eb"]]},{"id":"c9f1620f.3eab3","type":"debug","z":"89d730c1.41912","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":970,"y":60,"wires":[]},{"id":"f6ef04cc.bc5028","type":"debug","z":"89d730c1.41912","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":140,"wires":[]},{"id":"524d475.70352b8","type":"debug","z":"89d730c1.41912","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":100,"wires":[]},{"id":"a85a72e1.645eb","type":"debug","z":"89d730c1.41912","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":220,"wires":[]},{"id":"72f1220f.35076c","type":"debug","z":"89d730c1.41912","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":180,"wires":[]}]