Can some one help me get msg.payload to data dataTemp to function(scope) many Thanks...
i am beginner for node red ui code
Code:
[{"id":"66cb4ef1.3afa9","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"72261d28.63ecb4","type":"function","z":"66cb4ef1.3afa9","name":"randomData_0..100","func":"msg.payload = Math.round(Math.random()*100);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":180,"wires":[["7e6cded5.84a1f"]]},{"id":"7e6cded5.84a1f","type":"ui_template","z":"66cb4ef1.3afa9","group":"48190cbf.587d84","name":"","order":4,"width":"14","height":"6","format":"<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head runat=\"server\">\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n<title>Medidor Temperatura, Humedad</title>\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js\">\n</script>\n\n<script type=\"text/javascript\"\nsrc=\"https://www.gstatic.com/charts/loader.js\"></script>\n\n<script type=\"text/javascript\">\n google.charts.load('current', {\n packages: ['gauge']\n}).then(function () {\n var dataHumid = google.visualization.arrayToDataTable([\n ['Label', 'Value'],\n ['Humid', 0]\n ]);\n\n var dataTemp = google.visualization.arrayToDataTable([\n ['Label', 'Value'],\n ['Temp', 0]\n ]);\n\n var optionsHumid = {\n width: 170, height: 170,\n redFrom: 0, redTo: 33,\n yellowFrom: 33, yellowTo: 66,\n greenFrom: 66, greenTo: 100,\n majorTicks: ['0','10','20','30','40','50','60','70','80','90', '100'],\n minorTicks: 10\n };\n\n var formatHumid = new google.visualization.NumberFormat({\n suffix: '%',\n fractionDigits: 1\n });\n formatHumid.format(dataHumid, 1);\n\n var optionsTemp = {\n width: 170, height: 170,\n redFrom: 30, redTo: 45,\n yellowFrom: 24, yellowTo: 30,\n greenFrom: 12, greenTo: 24,\n majorTicks: ['0','10','20','30','40','50','60','70','80','90', '100'],\n minorTicks: 10\n };\n\n var formatTemp = new google.visualization.NumberFormat({\n suffix: 'h',\n fractionDigits: 1\n });\n formatTemp.format(dataTemp, 1);\n\n var chartHumid = new google.visualization.Gauge(document.getElementById(\"chart_Humid\"));\n var chartTemp = new google.visualization.Gauge(document.getElementById(\"chart_Temp\"));\n var ddt = 0;\n var ddt1 = 1;\n var ddt2 = 44;\n \n \n chartHumid.draw(dataHumid, optionsHumid);\n chartTemp.draw(dataTemp, optionsTemp);\n \n\n \n\n \n \n(function() {\n var count = 0\n function testit(msg,scope) {\n count = count+1;\n console.log(\"In testit \" + msg.payload + \" count = \" + count);\n scope.send({payload: \"from testit \" + msg.payload + \" count = \" + count});\n \n }\n var _data;\n (function(scope) {\n var _this = this;\n scope.$watch('msg.payload', function(data) {\n _this._data = dataTemp;\n });\n })(scope);\n \n \n \n\n});\n\n\nsetInterval(function() {\n /*\n var JSON=$.ajax({\n url:\"sensores.php\",\n dataType: 'json',\n async: false}).responseText;\n var Respuesta=jQuery.parseJSON(JSON);\n dataTemp.setValue(0, 1, Respuesta[0].temperature);\n */\n dataTemp.setValue(0, 1, 27.5);\n formatTemp.format(dataTemp, 1);\n chartTemp.draw(dataTemp, optionsTemp);\n }, 1300);\n\n\n})();\n</script>\n</head>\n<body>\n <p>{{msg.payload}}</p>\n <div class=\"gauge\" id=\"chart_Humid\"></div>\n <div class=\"gauge\" id=\"chart_Temp\"></div>\n</body>\n</html>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":600,"y":180,"wires":[[]]},{"id":"1f6219.ab303de7","type":"inject","z":"66cb4ef1.3afa9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":110,"y":180,"wires":[["72261d28.63ecb4"]]},{"id":"505efa6c.0e9bd4","type":"ui_template","z":"66cb4ef1.3afa9","d":true,"group":"48190cbf.587d84","name":"","order":4,"width":"14","height":"6","format":"<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head runat=\"server\">\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n<title>Medidor Temperatura, Humedad</title>\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js\">\n</script>\n\n<script type=\"text/javascript\"\nsrc=\"https://www.gstatic.com/charts/loader.js\"></script>\n\n<script type=\"text/javascript\">\n google.charts.load('current', {\n packages: ['gauge']\n}).then(function () {\n var dataHumid = google.visualization.arrayToDataTable([\n ['Label', 'Value'],\n ['Humid', 0]\n ]);\n\n var dataTemp = google.visualization.arrayToDataTable([\n ['Label', 'Value'],\n ['Temp', 0]\n ]);\n\n var optionsHumid = {\n width: 170, height: 170,\n redFrom: 0, redTo: 33,\n yellowFrom: 33, yellowTo: 66,\n greenFrom: 66, greenTo: 100,\n majorTicks: ['0','10','20','30','40','50','60','70','80','90', '100'],\n minorTicks: 10\n };\n\n var formatHumid = new google.visualization.NumberFormat({\n suffix: '%',\n fractionDigits: 1\n });\n formatHumid.format(dataHumid, 1);\n\n var optionsTemp = {\n width: 170, height: 170,\n redFrom: 30, redTo: 45,\n yellowFrom: 24, yellowTo: 30,\n greenFrom: 12, greenTo: 24,\n majorTicks: ['0','10','20','30','40','50','60','70','80','90', '100'],\n minorTicks: 10\n };\n\n var formatTemp = new google.visualization.NumberFormat({\n suffix: 'h',\n fractionDigits: 1\n });\n formatTemp.format(dataTemp, 1);\n\n var chartHumid = new google.visualization.Gauge(document.getElementById(\"chart_Humid\"));\n var chartTemp = new google.visualization.Gauge(document.getElementById(\"chart_Temp\"));\n var ddt = 0;\n var ddt1 = 1;\n var ddt2 = 44;\n \n \n chartHumid.draw(dataHumid, optionsHumid);\n chartTemp.draw(dataTemp, optionsTemp);\n \n\n setInterval(function() {\n /*\n var JSON=$.ajax({\n url:\"sensores.php\",\n dataType: 'json',\n async: false}).responseText;\n var Respuesta=jQuery.parseJSON(JSON);\n dataHumid.setValue(0, 1, Respuesta[0].humidity);\n */\n dataHumid.setValue(0, 1, 33);\n formatHumid.format(dataHumid, 1);\n chartHumid.draw(dataHumid, optionsHumid);\n \n \n \n }, 1300);\n\n setInterval(function() {\n /*\n var JSON=$.ajax({\n url:\"sensores.php\",\n dataType: 'json',\n async: false}).responseText;\n var Respuesta=jQuery.parseJSON(JSON);\n dataTemp.setValue(0, 1, Respuesta[0].temperature);\n */\n dataTemp.setValue(0, 1, 27.5);\n formatTemp.format(dataTemp, 1);\n chartTemp.draw(dataTemp, optionsTemp);\n }, 1300);\n \n(function() {\n var count = 0\n function testit(msg,scope) {\n count = count+1;\n console.log(\"In testit \" + msg.payload + \" count = \" + count);\n scope.send({payload: \"from testit \" + msg.payload + \" count = \" + count});\n \n }\n \n (function(scope) {\n scope.send({payload: \"preload\"}); // this gets sent when the view is opened in the browser\n scope.$watch('msg', function(msg) {\n if (msg) {\n testit(msg, scope);\n \n }\n });\n })(scope); \n\n});\n\n\n})();\n</script>\n</head>\n<body>\n <p>{{msg.payload}}</p>\n <div class=\"gauge\" id=\"chart_Humid\"></div>\n <div class=\"gauge\" id=\"chart_Temp\"></div>\n</body>\n</html>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":780,"y":80,"wires":[[]]},{"id":"48190cbf.587d84","type":"ui_group","name":"Default","tab":"711389cf.7d4e18","order":1,"disp":true,"width":"25","collapse":false},{"id":"711389cf.7d4e18","type":"ui_tab","name":"Home1","icon":"dashboard","disabled":false,"hidden":false}]