2022年9月30日 星期五

Node-Red 大里區空氣品質狀況

 Node-Red 大里區空氣品質狀況



  


 

flow.set("temp",msg.payload);

var rawdata = flow.get("temp");

 

var citynumber=rawdata.records.length;

var records_array=[];

var i;

for (i=0; i<citynumber;i++)

{

    records_array[i]=rawdata.records[i]

}

 

msg.payload=records_array;

flow.set("RECORDS",records_array);

 

return msg;a



var a = msg.payload;

 

a.forEach (function(e,i) {

   if(e.sitename =='大里') {

    msg.AQI = ' AQI=' + e['aqi'] ;

    msg.POL = ' AQI=' + e['pollutant'] ;

    msg.PM25 = ' PM2.5=' + e['pm2.5'] ;

    msg.PM25AVG = ' PM2.5 AVG=' + e['pm2.5_avg'] ;

    msg.Status = ' Status=' + e['status'] ;

    msg.PublishTime =' PublishTime='+ e['publishtime'] ;

    msg.payload='大里區'+msg.AQI+msg.PM25+msg.POL+msg.Status+msg.PublishTime;

 

    msg.AQI1 =  e['aqi'] ;

    msg.POL1 =  e['pollutant'] ;

    msg.PM251 = e['pm2.5'] ;

    msg.PM25AVG1 = e['pm2.5_avg'] ;

    msg.Status1 =  e['status'] ;

    msg.PublishTime1 = e['publishtime'] ;

   }

 } );

return msg;



 


29: object

sitename: "大里"

county: "臺中市"

aqi: "64"

pollutant: "細懸浮微粒"

status: "普通"

so2: "2.1"

co: "0.44"

o3: "28.5"

o3_8hr: "58.4"

pm10: "38"

pm2.5: "22"

no2: "22"

nox: "23.3"

no: "1.2"

wind_speed: "1.3"

wind_direc: "2"

publishtime: "2022/09/30 19:00:00"

co_8hr: "0.3"

pm2.5_avg: "20"

pm10_avg: "45"

so2_avg: "2"

longitude: "120.67844444"

latitude: "24.09961111"

siteid: "30"

 




array[86]

[0 … 9]

0: object

sitename: "基隆"

county: "基隆市"

aqi: "20"

pollutant: ""

status: "良好"

so2: ""

co: "0.19"

o3: "18"

o3_8hr: "19.1"

pm10: "18"

pm2.5: "11"

no2: "4.3"

nox: "5.7"

no: "1.4"

wind_speed: "0.9"

wind_direc: "94"

publishtime: "2022/09/30 19:00:00"

co_8hr: "0.1"

pm2.5_avg: "6"

pm10_avg: "10"

so2_avg: "0"

longitude: "121.760056"

latitude: "25.129167"

siteid: "1"

 




[{"id":"a0e05e56b90ecabf","type":"tab","label":"流程6","disabled":false,"info":"","env":[]},{"id":"784cb713.fa8498","type":"inject","z":"a0e05e56b90ecabf","name":"","repeat":"20","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":100,"y":140,"wires":[["ae1e2fd0.e0a9a"]]},{"id":"ae1e2fd0.e0a9a","type":"http request","z":"a0e05e56b90ecabf","name":"AQI網頁","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://data.epa.gov.tw/api/v2/aqx_p_432?api_key=e8dd42e6-9b8b-43f8-991e-b3dee723a52d&limit=1000&sort=ImportDate%20desc&format=JSON","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":240,"y":140,"wires":[["d51b6fa7448dc94c","8850bfb05c7ca503"]]},{"id":"48068d3d.60f764","type":"function","z":"a0e05e56b90ecabf","name":"大里","func":"var a = msg.payload;\n\na.forEach (function(e,i) {\n   if(e.sitename =='大里') {\n    msg.AQI = ' AQI=' + e['aqi'] ;\n    msg.POL = ' AQI=' + e['pollutant'] ;\n    msg.PM25 = ' PM2.5=' + e['pm2.5'] ;\n    msg.PM25AVG = ' PM2.5 AVG=' + e['pm2.5_avg'] ;\n    msg.Status = ' Status=' + e['status'] ;\n    msg.PublishTime =' PublishTime='+ e['publishtime'] ;\n    msg.payload='大里區'+msg.AQI+msg.PM25+msg.POL+msg.Status+msg.PublishTime;\n\n    msg.AQI1 =  e['aqi'] ;\n    msg.POL1 =  e['pollutant'] ;\n    msg.PM251 = e['pm2.5'] ;\n    msg.PM25AVG1 = e['pm2.5_avg'] ;\n    msg.Status1 =  e['status'] ;\n    msg.PublishTime1 = e['publishtime'] ;\n   }\n } );\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":160,"wires":[["d3e21d7.40a21e","f26b5812.ee3d18","16cd5db5.17a012","83d0f322.82d48","33fc5a97.f9cd36","148f161.fc68fea","2932333a.810e1c","ffb7537c.5fcc","cbd33403.ed5f58"]]},{"id":"d3e21d7.40a21e","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"PM25","statusVal":"","statusType":"auto","x":760,"y":60,"wires":[]},{"id":"f26b5812.ee3d18","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"Status","x":760,"y":100,"wires":[]},{"id":"16cd5db5.17a012","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"PublishTime","x":780,"y":140,"wires":[]},{"id":"83d0f322.82d48","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"AQI","x":750,"y":180,"wires":[]},{"id":"2d19b1a2.c2283e","type":"comment","z":"a0e05e56b90ecabf","name":"大里區空氣品質狀況","info":"","x":110,"y":100,"wires":[]},{"id":"33fc5a97.f9cd36","type":"mqtt out","z":"a0e05e56b90ecabf","name":"大里AQI","topic":"alex9ufo/Dali/AQI","qos":"1","retain":"true","broker":"40bf4d5e.0395f4","x":560,"y":60,"wires":[]},{"id":"5e616d1c.5f5204","type":"ui_gauge","z":"a0e05e56b90ecabf","name":"","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"3","gtype":"gage","title":"PM2.5 [0..35] 良好","label":"units","format":"{{value}}","min":0,"max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"35","seg2":"53","x":880,"y":240,"wires":[],"inputLabels":["msg.PM25"]},{"id":"fc41b156.17017","type":"ui_text","z":"a0e05e56b90ecabf","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"2","name":"","label":"空氣品質","format":"{{msg.payload}}","layout":"row-spread","x":850,"y":400,"wires":[],"inputLabels":["msg.payload"]},{"id":"148f161.fc68fea","type":"function","z":"a0e05e56b90ecabf","name":"PM2.5 [0..80]","func":"msg.payload=msg.PM251;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":260,"wires":[["5e616d1c.5f5204","4f0344d6.7bf2dc"]]},{"id":"4f0344d6.7bf2dc","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":280,"wires":[]},{"id":"2932333a.810e1c","type":"function","z":"a0e05e56b90ecabf","name":"AQI [0..400]","func":"msg.payload= msg.AQI1;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":340,"wires":[["e22444a1.5dda48","9d489604.c1ea28"]]},{"id":"e22444a1.5dda48","type":"ui_gauge","z":"a0e05e56b90ecabf","name":"","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"3","gtype":"gage","title":"AQI [0..50] 良好","label":"units","format":"{{value}}","min":0,"max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"50","seg2":"100","className":"","x":870,"y":320,"wires":[],"inputLabels":["msg.PM25"]},{"id":"ffb7537c.5fcc","type":"function","z":"a0e05e56b90ecabf","name":"Status","func":"msg.payload=msg.Status1;\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":420,"wires":[["fc41b156.17017","33bed4d0.fc4e0c"]]},{"id":"cbd33403.ed5f58","type":"function","z":"a0e05e56b90ecabf","name":"PublishTime","func":"msg.payload=msg.PublishTime1;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":500,"wires":[["5c529cd1.1170b4","ca7e38c9.45dc98"]]},{"id":"5c529cd1.1170b4","type":"ui_text","z":"a0e05e56b90ecabf","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"3","name":"","label":"發表時間","format":"{{msg.payload}}","layout":"row-spread","x":850,"y":480,"wires":[],"inputLabels":["msg.payload"]},{"id":"9d489604.c1ea28","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":360,"wires":[]},{"id":"33bed4d0.fc4e0c","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":440,"wires":[]},{"id":"ca7e38c9.45dc98","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":520,"wires":[]},{"id":"d51b6fa7448dc94c","type":"debug","z":"a0e05e56b90ecabf","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":260,"y":220,"wires":[]},{"id":"8850bfb05c7ca503","type":"function","z":"a0e05e56b90ecabf","name":"function 5","func":"\nflow.set(\"temp\",msg.payload);\nvar rawdata = flow.get(\"temp\");\n\nvar citynumber=rawdata.records.length;\nvar records_array=[];\nvar i;\nfor (i=0; i<citynumber;i++)\n{\n    records_array[i]=rawdata.records[i]\n}\n\nmsg.payload=records_array;\nflow.set(\"RECORDS\",records_array);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":80,"wires":[["48068d3d.60f764","b398f49598b605af"]]},{"id":"b398f49598b605af","type":"debug","z":"a0e05e56b90ecabf","name":"debug 7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":380,"y":20,"wires":[]},{"id":"40bf4d5e.0395f4","type":"mqtt-broker","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":15,"cleansession":true,"birthQos":"0","willQos":"0"},{"id":"ac7bd49c.51cf38","type":"ui_group","name":"大里區空氣品質狀況","tab":"ba052423.3729f8","order":1,"disp":true,"width":"6","collapse":false},{"id":"ba052423.3729f8","type":"ui_tab","name":"AQI","icon":"dashboard","order":1}]

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...