Node Red Cannot Read Property 'addlistener' of Undefined"

Im trying to create a Dashboard connected to my Database. Everything works fine, but when i attempt to filter the event with a SQL Query im getting the Error :

"TypeError: Cannot read property 'payload' of undefined"

If i cut the Date-part out the output still works.

Debug_Window Picture of my nodes

  1. Date-part (Picking 2 Dates and try to show informations between these)
  2. SQL-Query + Connection + Output to Table
  3. Filter past Machine_ID (MAT4 and MAT6 are the Machine_Names)


Node-Red


Function Node throwing fault:

          [{"id":"a87a533e.7502c","type":"office","z":"5c6013ad.23ba3c","name":"Query_ID","func":"var machine_id = msg.machineId.payload;\nvar beginDate = msg.begindate.payload;\nvar endDate = msg.enddate.payload;\n\n\n\nmsg.topic = \"SELECT processdata.time,eqpm_machines.name AS machine_name,tags.Id As tags_no,tags.name,processdata.value,tags.units,processdata.item_serial_no FROM processdata JOIN tags ON processdata.tag_id=tags.Id JOIN eqpm_machines ON processdata.machine_id=eqpm_machines.Id WHERE 1\";\n\nif(machine_id !== 0){\n    msg.topic = msg.topic + \" AND processdata.machine_id = \" + machine_id ;\north}\north\north\nif(beginDate !== \"\" && endDate !== \"\"){\n    msg.topic = msg.topic + \" AND processdata.time >= '\" + beginDate + \"' AND processdata.time <= '\" + endDate + \"'\" ;\n}\n\n\nif(i == 1){\n    msg.topic = msg.topic + \";\";\north}\north\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":140,"wires":[["527131e3.e2df","95da523b.7b8f"]]}]                  

All Nodes:

          [{"id":"70cb9a7a.7d32f4","blazon":"subflow","name":"Dropdown_for_MachineID","info":"","in":[{"ten":200,"y":180,"wires":[{"id":"5698dce4.98ed94"}]}],"out":[{"ten":900,"y":320,"wires":[{"id":"ab37a9a2.6d2648","port":0}]}]},{"id":"785c286a.4073e8","type":"mysql","z":"70cb9a7a.7d32f4","mydb":"6f90c35b.00d35c","proper name":"","x":530,"y":200,"wires":[["4b472402.9312dc","525cddf2.159384"]]},{"id":"3ad59ab4.36a996","blazon":"inject","z":"70cb9a7a.7d32f4","name":"","topic":"","payload":"","payloadType":"date","echo":"","crontab":"","once":false,"onceDelay":0.one,"x":220,"y":280,"wires":[["5698dce4.98ed94"]]},{"id":"5698dce4.98ed94","type":"part","z":"70cb9a7a.7d32f4","name":"Query","func":"var id = msg.payload.id;\nvar machine_id = msg.payload.machine_id;\nvar tag_id = msg.payload.tag_id;\north\nmsg.topic = \"SELECT processdata.Id,processdata.time,eqpm_machines.Id As machine_id ,eqpm_machines.proper name AS machine_name,tags.Id Every bit tags_no,tags.name,processdata.value,tags.units,processdata.item_serial_no FROM processdata JOIN tags ON processdata.tag_id=tags.Id Bring together eqpm_machines ON processdata.machine_id=eqpm_machines.Id GROUP BY machine_id HAVING ane\";\n\north\north/*\nif(machine_id !== \"\"){\northward    msg.topic = msg.topic + \" AND processdata.machine_id =\" + machine_id ;\n}\n\nif(tag_id !== \"\"){\n    msg.topic = msg.topic + \" AND processdata.tag_id=  \" + tag_id ;\n}\northward\due north\nif(1 == ane){\n //   msg.topic = msg.topic + \"AND INNER JOIN \";\northward    msg.topic = msg.topic + \";\";\n}\due north*/\n\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":200,"wires":[["785c286a.4073e8"]]},{"id":"ab37a9a2.6d2648","type":"function","z":"70cb9a7a.7d32f4","proper noun":"","func":"msg.options = msg.payload;\nreturn msg;\n\n","outputs":1,"noerr":0,"x":710,"y":320,"wires":[[]]},{"id":"525cddf2.159384","type":"change","z":"70cb9a7a.7d32f4","proper noun":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.{machine_name:machine_id}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":faux,"ten":600,"y":420,"wires":[["9e25a7e5.868ff8","ab37a9a2.6d2648"]]},{"id":"9e25a7e5.868ff8","type":"debug","z":"70cb9a7a.7d32f4","name":"","active":truthful,"tosidebar":true,"console":simulated,"tostatus":false,"complete":"false","x":810,"y":420,"wires":[]},{"id":"4b472402.9312dc","type":"debug","z":"70cb9a7a.7d32f4","proper noun":"","active":true,"tosidebar":truthful,"console":faux,"tostatus":false,"consummate":"false","x":710,"y":160,"wires":[]},{"id":"de4f6679.aaa758","type":"tab","label":"Flow iv","disabled":false,"info":""},{"id":"77006751.545558","type":"mysql","z":"de4f6679.aaa758","mydb":"6f90c35b.00d35c","name":"Datenbank","10":1050,"y":380,"wires":[["6f674497.02751c","d2ca02c6.d422e","e222ef82.8faae"]]},{"id":"2f8e5fc5.9e2de","type":"part","z":"de4f6679.aaa758","proper name":"Query_ID","func":"var machine_id = msg.machineId.payload;\nvar beginn_date = msg.payload.begindate.payload;\nvar end_date = msg.payload.enddate.payload;\n\nmsg.topic = \"SELECT processdata.time,eqpm_machines.name AS machine_name,tags.Id AS tags_no,tags.proper noun,processdata.value,tags.units,processdata.item_serial_no FROM processdata Bring together tags ON processdata.tag_id=tags.Id Join eqpm_machines ON processdata.machine_id=eqpm_machines.Id WHERE one\";\n\nif(machine_id !== \"\" && beginn_date !== \"\" && end_date !==\"\"){\n    msg.topic = msg.topic + \" AND processdata.machine_id =\" + machine_id + \" AND processdata.time >= \" + beginn_date + \" AND processdata.fourth dimension <= \" + end_date;\due north}\n\nif(ane == i){\n //   msg.topic = msg.topic + \"AND INNER Join \";\n    msg.topic = msg.topic + \";\";\northward}\due north\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":380,"wires":[["77006751.545558","1478fccf.a8a3d3"]]},{"id":"d2ca02c6.d422e","type":"json","z":"de4f6679.aaa758","name":"","property":"payload","activeness":"","pretty":false,"ten":1250,"y":380,"wires":[["23afecf2.d72d14"]]},{"id":"6f674497.02751c","blazon":"debug","z":"de4f6679.aaa758","proper name":"DATABASE","agile":false,"tosidebar":true,"console":false,"tostatus":false,"consummate":"payload","x":1050,"y":340,"wires":[]},{"id":"1478fccf.a8a3d3","blazon":"debug","z":"de4f6679.aaa758","name":"QUERY_ID","active":faux,"tosidebar":true,"console":fake,"tostatus":false,"consummate":"truthful","ten":850,"y":340,"wires":[]},{"id":"e222ef82.8faae","blazon":"ui_template","z":"de4f6679.aaa758","grouping":"2efc921b.eeb7de","name":"Output_Table","gild":one,"width":"18","tiptop":"xi","format":"<style>\north {\n    font-family: \"Trebuchet MS\", Arial, Helvetica, sans-serif;\n    border-plummet: collapse;\n    width: 100%;\due north    postion: solid;\northward}\n\ntd, th {\n    border: 1px solid #ddd;\due north    padding: 8px;\n}\n\ntr:nth-kid(even){background-color: #f2f2f2;}\n\ntr:hover {background-color: #ddd;}\n\nth {\due north    padding-height: 12px;\n    padding-bottom: 12px;\n    text-marshal: left;\n    background-color: #2a71d4;\n    colour: white;\north}\northward</style>\n\n<tabular array>\n    <tr>\n        <th>Time</th>\n        <thursday>Car</th>\due north        <thursday>Tag_ID</th>\due north        <th>Value</thursday>\n        <th>Unit</th>\n        <th>Item_Serial_No</th>\n    </tr>\northward  <tr ng-repeat=\"payload in msg.payload\">\n    <td>{{ payload.time }}</td>\n    <td>{{ payload.machine_name }} </td>\north    <td>{{ payload.proper name }} </td>\northward    <td>{{ payload.value }} </td>\n    <td>{{ payload.units}}</td>\n    <td>{{ payload.item_serial_no }} </td>\north  </tr>\northward</tabular array>","storeOutMessages":fake,"fwdInMessages":true,"templateScope":"local","ten":1250,"y":420,"wires":[[]]},{"id":"23afecf2.d72d14","blazon":"debug","z":"de4f6679.aaa758","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"consummate":"payload","x":1250,"y":340,"wires":[]},{"id":"c6044e3.2372bb","type":"inject","z":"de4f6679.aaa758","name":"","topic":"","payload":"Started!","payloadType":"str","echo":"","crontab":"","once":true,"onceDelay":"","x":220,"y":240,"wires":[["452ea09d.3dff1"]]},{"id":"1036ce2b.9809f2","type":"ui_button","z":"de4f6679.aaa758","proper noun":"Button_ID_All","group":"9e579e53.ca3d","social club":0,"width":"half-dozen","top":"1","passthru":false,"characterization":"Prove all","color":"","bgcolor":"","icon":"","payload":" ","payloadType":"str","topic":"Button_Reset","x":440,"y":440,"wires":[["2f8e5fc5.9e2de"]]},{"id":"452ea09d.3dff1","type":"delay","z":"de4f6679.aaa758","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","charge per unit":"i","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":230,"y":440,"wires":[["1036ce2b.9809f2","64318e66.b5cad"]]},{"id":"64318e66.b5cad","type":"subflow:70cb9a7a.7d32f4","z":"de4f6679.aaa758","name":"","x":370,"y":380,"wires":[["be714c06.a52f1"]]},{"id":"be714c06.a52f1","type":"ui_dropdown","z":"de4f6679.aaa758","name":"","label":"","place":"Select option","grouping":"9e579e53.ca3d","club":0,"width":0,"acme":0,"passthru":truthful,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":580,"y":380,"wires":[["2f8e5fc5.9e2de","52a3f69.79b2e08"]]},{"id":"52a3f69.79b2e08","type":"function","z":"de4f6679.aaa758","name":"SET_FLOW","func":"flow.set up(\"machineId\",msg.payload);\nreturn msg;\north","outputs":one,"noerr":0,"x":610,"y":140,"wires":[["e0e22ca1.2bcbd"]]},{"id":"d858418c.b956d","type":"debug","z":"de4f6679.aaa758","proper name":"","active":truthful,"tosidebar":true,"console":false,"tostatus":fake,"complete":"true","x":770,"y":160,"wires":[]},{"id":"e0e22ca1.2bcbd","type":"function","z":"de4f6679.aaa758","name":"GET_FLOW","func":"var from_input = msg._fromInput;\n\n    var machineId = {payload: catamenia.get(\"machineId\")};\due north    msg.machineId = machineId;\n\nreturn msg;","outputs":one,"noerr":0,"x":610,"y":180,"wires":[["d858418c.b956d","2f8e5fc5.9e2de"]]},{"id":"7838fe98.cc06a","type":"ui_template","z":"de4f6679.aaa758","group":"5b074627.dbdca8","name":"StartDate","order":0,"width":"6","acme":"4","format":"<!DOCTYPE html>\due north<html lang=\"en\">\northward<head>\n  <title>Bootstrap Instance</title>\n  <meta charset=\"utf-viii\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=ane\">\n  <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\">\north  <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.three.1/jquery.min.js\"></script>\n  <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.seven/js/bootstrap.min.js\"></script>\n\north</caput>\n<body>\n    \n    <form activeness=\"/ui\" method=\"mail\">\n        <div id=\"appointment\">Begin:</div>\northward        <input type=\"datetime-local\" name=\"begindate\" id=\"bdate\" value=\"2013-10-24T20:36:00\" pace=\"one\">\north        <br>\north        <div id=\"date\">to End:</div>\north        <input blazon=\"datetime-local\" proper name=\"enddate\" id=\"edate\" value=\"2013-10-24T20:36:00\" footstep=\"i\">\n        <br><br>\north        <input type=\"submit\" id=\"submit\">\due north      </class>\n      \n      <div id=\"divdiv\">L</div>\n\due north<script src=\"./alphabetize.js\"></script>\n\n</trunk>\n</html>\n","storeOutMessages":true,"fwdInMessages":truthful,"templateScope":"local","ten":300,"y":660,"wires":[["3898d89c.e7fbb8"]]},{"id":"ff37db30.247b08","blazon":"ui_template","z":"de4f6679.aaa758","group":"4f219b41.f1f344","proper name":"JS","order":0,"width":0,"height":0,"format":"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>\n<script>\n\n\"utilize strict\";\northward\north        \n\due north});\n\northward\n    \n\n   function Rep(whenDate, alphabetize, replacement,elementID) {\due north        var str = whenDate;\n        str = setCharAt(str,index,replacement);\due north        document.getElementById(elementID).innerText = \"Time: \" + str;\n\n}\n\northward    function setCharAt(str,index,chr) {\due north        if(alphabetize > str.length-1) return str;\n        return str.substr(0,index) + chr + str.substr(alphabetize+one);\due north}\north\n\ndocument.getElementById(\"submit\").addEventListener(\"click\", office(){\northward\due north    //event.preventDefault();\n\northward    let beginDate = document.getElementById(\"bdate\").value;\n    let endDate = certificate.getElementById(\"edate\").value;\due north\n\tRep(beginDate, 10, \" \",\"begindatetimetext\");\n    Rep(endDate, x, \" \",\"enddatetimetext\");\n\n});\n//JQuery\n\n $(document).ready(part(){\n     \n    permit dropdown__change = document.getElementById(\"select_value_label_0\");\northward     \n    $(\"#submit\").click(function(){\n        $.post(\"/ui\",\north        {\due north          dropdown__status: \n        },\n    });\n});\n\north\north\n</script>","storeOutMessages":truthful,"fwdInMessages":true,"templateScope":"local","x":290,"y":620,"wires":[[]]},{"id":"3898d89c.e7fbb8","blazon":"http response","z":"de4f6679.aaa758","name":"","statusCode":"","headers":{},"x":430,"y":660,"wires":[]},{"id":"b1d800ef.d4a16","blazon":"http in","z":"de4f6679.aaa758","name":"","url":"/ui","method":"post","upload":faux,"swaggerDoc":"","x":300,"y":700,"wires":[["88ad979d.dac068"]]},{"id":"88ad979d.dac068","type":"role","z":"de4f6679.aaa758","name":"REMOVE_T_FROM_DATE","func":"    msg.payload.begindate = {payload:msg.payload.begindate.supercede(/T/chiliad, \" \")};\north    msg.payload.enddate = {payload:msg.payload.enddate.replace(/T/g, \" \")};\due north    render msg;\n    ","outputs":1,"noerr":0,"x":500,"y":700,"wires":[["ff18db4a.19e958"]]},{"id":"ff18db4a.19e958","type":"function","z":"de4f6679.aaa758","name":"SET_FLOW","func":"period.set(\"begindate\",msg.payload.begindate);\nflow.set(\"enddate\",msg.payload.enddate);\n\nreturn msg;\n","outputs":1,"noerr":0,"ten":650,"y":660,"wires":[["e0eb0b34.d41488"]]},{"id":"e0eb0b34.d41488","blazon":"function","z":"de4f6679.aaa758","name":"GET_FLOW","func":"msg.begindate = flow.get(\"begindate\")\nmsg.enddate = flow.get(\"enddate\")\nreturn msg;","outputs":ane,"noerr":0,"x":670,"y":620,"wires":[["79bd9f2f.3fffa","2f8e5fc5.9e2de"]]},{"id":"79bd9f2f.3fffa","type":"debug","z":"de4f6679.aaa758","name":"","active":true,"tosidebar":true,"console":simulated,"tostatus":fake,"consummate":"false","10":890,"y":600,"wires":[]},{"id":"6f90c35b.00d35c","type":"MySQLdatabase","z":"","host":"localhost","port":"","db":"pda","tz":""},{"id":"2efc921b.eeb7de","type":"ui_group","z":"de4f6679.aaa758","proper name":"Output_Table","tab":"f5df333.e4490d","social club":4,"disp":true,"width":"18","collapse":false},{"id":"9e579e53.ca3d","type":"ui_group","z":"","name":"Button","tab":"f5df333.e4490d","disp":true,"width":"vi","collapse":imitation},{"id":"5b074627.dbdca8","type":"ui_group","z":"","name":"Engagement","tab":"f5df333.e4490d","disp":true,"width":"6","collapse":fake},{"id":"4f219b41.f1f344","type":"ui_group","z":"5c6013ad.23ba3c","proper noun":"Output_Table","tab":"e4025f2e.5474c","gild":four,"disp":truthful,"width":"xviii","collapse":false},{"id":"f5df333.e4490d","type":"ui_tab","z":"de4f6679.aaa758","proper noun":"Attendorn","icon":"dashboard","order":ane},{"id":"e4025f2e.5474c","type":"ui_tab","z":"5c6013ad.23ba3c","name":"Attendorn","icon":"dashboard","order":i}]                  

martingrout2001.blogspot.com

Source: https://stackoverflow.com/questions/51102386/node-red-typeerror-cannot-read-property-payload-of-undefined

0 Response to "Node Red Cannot Read Property 'addlistener' of Undefined""

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel