2019年10月10日 星期四

政府資料開放平台紫外線即時監測資料細懸浮微粒資料(PM2.5)

政府資料開放平台

紫外線即時監測資料

http://opendata.epa.gov.tw/ws/Data/UV/?format=json

細懸浮微粒資料(PM2.5)


http://opendata.epa.gov.tw/ws/Data/REWXQA/?$orderby=SiteName&$skip=0&$top=1000&format=json










Node-RED

[{"id":"68241010.951b2","type":"http in","z":"23b81440.98563c","name":"get UVI","url":"/UVI","method":"get","upload":false,"swaggerDoc":"","x":70,"y":160,"wires":[["46ba76c3.af8238","8b9681ca.4c1d4","c98caf92.b7deb"]]},{"id":"46ba76c3.af8238","type":"http request","z":"23b81440.98563c","name":"UVI request","method":"GET","ret":"txt","url":"http://opendata.epa.gov.tw/ws/Data/UV/?format=json","tls":"","x":248,"y":159,"wires":[["6be95f1f.b54b","fc52ad45.8b8a9"]]},{"id":"182b1a6e.52acd6","type":"http response","z":"23b81440.98563c","name":"","x":756,"y":158,"wires":[]},{"id":"fc52ad45.8b8a9","type":"debug","z":"23b81440.98563c","name":"UVImessage","active":false,"console":"false","complete":"payload","x":410,"y":220,"wires":[]},{"id":"6be95f1f.b54b","type":"json","z":"23b81440.98563c","name":"json","x":395,"y":157,"wires":[["e427f419.aec198","4a66b3f5.d7e47c"]]},{"id":"50c2818f.a1ada","type":"http in","z":"23b81440.98563c","name":"get air","url":"/air","method":"get","swaggerDoc":"","x":70,"y":380,"wires":[["b82c7506.573fa8","aff1dbd1.c42db8"]]},{"id":"b82c7506.573fa8","type":"http request","z":"23b81440.98563c","name":"air request","method":"GET","ret":"txt","url":"http://opendata.epa.gov.tw/ws/Data/REWXQA/?$orderby=SiteName&$skip=0&$top=1000&format=json","tls":"","x":250,"y":400,"wires":[["fb541b8d.9087e8"]]},{"id":"e427f419.aec198","type":"function","z":"23b81440.98563c","name":"UVI data process","func":"var n=context.global.uvnum;\nvar data=msg.payload;\nvar SiteName;\nvar UVI;\nvar County;\nvar time;\ntry\n{\nSiteName= data[n].SiteName;\nUVI= data[n].UVI;\nCounty=data[n].County;\ntime=data[n].PublishTime;\n}\ncatch(err) \n{\n SiteName= data[0].SiteName;\nUVI= data[0].UVI;\nCounty=data[0].County;\ntime=data[0].PublishTime;\n   \n}\n\n\nmsg.payload={\"SiteName\": County+SiteName, \"UVI\":UVI, \"time\":time};\n//msg.payload=data;\nreturn msg;","outputs":1,"noerr":0,"x":568,"y":159,"wires":[["182b1a6e.52acd6","8b5a9baf.170e78"]]},{"id":"8b5a9baf.170e78","type":"debug","z":"23b81440.98563c","name":"UVI process message","active":true,"console":"false","complete":"payload","x":720,"y":240,"wires":[]},{"id":"8b9681ca.4c1d4","type":"function","z":"23b81440.98563c","name":"Set context.global.uvnum","func":"context.global.uvnum=msg.payload.uvnum;\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":100,"wires":[[]]},{"id":"c98caf92.b7deb","type":"debug","z":"23b81440.98563c","name":"monitor http in","active":false,"console":"false","complete":"payload","x":177,"y":223,"wires":[]},{"id":"a6a3efc9.cd1d6","type":"http response","z":"23b81440.98563c","name":"http out","x":780,"y":400,"wires":[]},{"id":"53522679.a75108","type":"debug","z":"23b81440.98563c","name":"air process message","active":false,"console":"false","complete":"payload","x":760,"y":440,"wires":[]},{"id":"1419d1c4.bcab5e","type":"function","z":"23b81440.98563c","name":"air data process","func":"var n=context.global.airnum;\nvar data=msg.payload;\nvar JSONtostring = JSON.stringify(data);\nvar res = JSONtostring.replace(/PM2.5/gi, \"PM2point5\");\nvar airobj = JSON.parse(res);\n\nvar SiteName;\nvar County;\nvar PM2point5;\nvar time;\ntry{\nSiteName=airobj[n].SiteName;\nCounty=airobj[n].County;\nPM2point5=airobj[n].PM2point5;\ntime=airobj[n].PublishTime;\n}\ncatch(err)\n{\n SiteName=airobj[0].SiteName;\nCounty=airobj[0].County;\nPM2point5=airobj[0].PM2point5;\ntime=airobj[0].PublishTime;   \n}\n\nmsg.payload={\"SiteName\": County+SiteName, \"PM2point5\":PM2point5, \"time\":time};\n\n\n//msg.payload=airobj;\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":400,"wires":[["a6a3efc9.cd1d6","53522679.a75108"]]},{"id":"aff1dbd1.c42db8","type":"function","z":"23b81440.98563c","name":"Set context.global.airnum","func":"context.global.airnum=msg.payload.airnum;\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":340,"wires":[[]]},{"id":"fb541b8d.9087e8","type":"json","z":"23b81440.98563c","name":"json","x":410,"y":400,"wires":[["1419d1c4.bcab5e"]]},{"id":"4a66b3f5.d7e47c","type":"debug","z":"23b81440.98563c","name":"jsonobject","active":false,"console":"false","complete":"payload","x":556,"y":57,"wires":[]},{"id":"17949595.bd2bba","type":"comment","z":"23b81440.98563c","name":"UVI紫外線即時監測資料","info":"","x":120,"y":60,"wires":[]},{"id":"38f5fc2c.5a3a14","type":"comment","z":"23b81440.98563c","name":"細懸浮微粒資料(PM2.5)","info":"","x":130,"y":300,"wires":[]},{"id":"209cf536.1616ca","type":"inject","z":"23b81440.98563c","name":"","topic":"","payload":"","payloadType":"date","repeat":"20","crontab":"","once":true,"onceDelay":"5","x":110,"y":620,"wires":[["4b404974.e341d8"]]},{"id":"4b404974.e341d8","type":"http request","z":"23b81440.98563c","name":"AQI網頁","method":"GET","ret":"obj","url":"http://opendata.epa.gov.tw/ws/Data/REWIQA/?$orderby=SiteName&$skip=0&$top=1000&format=json","tls":"","x":260,"y":620,"wires":[["be7acd09.61747"]]},{"id":"be7acd09.61747","type":"function","z":"23b81440.98563c","name":"大里","func":"var a = msg.payload;\n\na.forEach (function(e,i) {\n   if(e.SiteName =='大里') {\n    msg.PM25 = ' PM2.5=' + e['PM2.5'] ;\n    msg.AQI = ' AQI=' + e['AQI'] ;\n    msg.Status = ' Status=' + e['Status'] ;\n    msg.PublishTime =' PublishTime='+ e['PublishTime'] ;\n    msg.payload='大里區'+msg.PM25+msg.AQI+msg.Status+msg.PublishTime;\n\n    msg.PM251 =  e['PM2.5'] ;\n    msg.AQI1 =  e['AQI'] ;\n    msg.Status1 = e['Status'] ;\n    msg.PublishTime1 = e['PublishTime'] ;\n   \n   }\n } );\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":620,"wires":[["94155c48.9e4a3","8d11a34f.6f3c9","689da6e3.ca0cd8","25fb2d81.c8bab2","3c53f309.4a120c","2167937.d58fe6c","5f789b1c.e908a4","d9f997bc.58e438","ea5f38d6.92bd48"]]},{"id":"94155c48.9e4a3","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"PM25","x":690,"y":540,"wires":[]},{"id":"8d11a34f.6f3c9","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"Status","x":690,"y":580,"wires":[]},{"id":"689da6e3.ca0cd8","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"PublishTime","x":710,"y":620,"wires":[]},{"id":"25fb2d81.c8bab2","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"AQI","x":680,"y":660,"wires":[]},{"id":"9debb1a1.7c4d4","type":"comment","z":"23b81440.98563c","name":"大里區空氣品質狀況","info":"","x":110,"y":580,"wires":[]},{"id":"3c53f309.4a120c","type":"mqtt out","z":"23b81440.98563c","name":"大里AQI","topic":"alex9ufo/Dali/AQI","qos":"1","retain":"true","broker":"41c07aec.1d13f4","x":520,"y":540,"wires":[]},{"id":"43005dc6.2d9f14","type":"ui_gauge","z":"23b81440.98563c","name":"","group":"6bcc7411.b1398c","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":810,"y":700,"wires":[],"inputLabels":["msg.PM25"]},{"id":"da7dbb4a.81d6b8","type":"ui_text","z":"23b81440.98563c","group":"6bcc7411.b1398c","order":0,"width":"6","height":"2","name":"","label":"空氣品質","format":"{{msg.payload}}","layout":"row-spread","x":700,"y":880,"wires":[],"inputLabels":["msg.payload"]},{"id":"2167937.d58fe6c","type":"function","z":"23b81440.98563c","name":"PM2.5 [0..80]","func":"msg.payload=msg.PM251;\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":720,"wires":[["43005dc6.2d9f14","d34aca16.6f7de8"]]},{"id":"d34aca16.6f7de8","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":790,"y":740,"wires":[]},{"id":"5f789b1c.e908a4","type":"function","z":"23b81440.98563c","name":"AQI [0..400]","func":"msg.payload= msg.AQI1;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":800,"wires":[["589861a9.fc54f","6cb0dcba.5b2a64"]]},{"id":"589861a9.fc54f","type":"ui_gauge","z":"23b81440.98563c","name":"","group":"6bcc7411.b1398c","order":0,"width":"6","height":"3","gtype":"gage","title":"AQI [0..50] 良好","label":"units","format":"{{value}}","min":0,"max":"400","colors":["#00b500","#e6e600","#ca3838"],"seg1":"50","seg2":"100","x":780,"y":800,"wires":[],"inputLabels":["msg.PM25"]},{"id":"d9f997bc.58e438","type":"function","z":"23b81440.98563c","name":"Status","func":"msg.payload=msg.Status1;\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":900,"wires":[["da7dbb4a.81d6b8","edfd8cb6.9437a"]]},{"id":"ea5f38d6.92bd48","type":"function","z":"23b81440.98563c","name":"PublishTime","func":"msg.payload=msg.PublishTime1;\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":980,"wires":[["da0c11d3.7b429","c8653292.87ded"]]},{"id":"da0c11d3.7b429","type":"ui_text","z":"23b81440.98563c","group":"6bcc7411.b1398c","order":0,"width":"6","height":"3","name":"","label":"發表時間","format":"{{msg.payload}}","layout":"row-spread","x":700,"y":960,"wires":[],"inputLabels":["msg.payload"]},{"id":"6cb0dcba.5b2a64","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":770,"y":840,"wires":[]},{"id":"edfd8cb6.9437a","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":710,"y":920,"wires":[]},{"id":"c8653292.87ded","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":710,"y":1000,"wires":[]},{"id":"3039d094.cf874","type":"comment","z":"23b81440.98563c","name":"http://opendata.epa.gov.tw/ws/Data/REWIQA/?$orderby=SiteName&$skip=0&$top=1000&format=json","info":"","x":370,"y":500,"wires":[]},{"id":"33aa8e6.0794372","type":"inject","z":"23b81440.98563c","name":"","topic":"","payload":"","payloadType":"date","repeat":"20","crontab":"","once":true,"onceDelay":"5","x":110,"y":1120,"wires":[["44618b12.6f8cc4","d8ca9a21.15b7d8"]]},{"id":"44618b12.6f8cc4","type":"http request","z":"23b81440.98563c","name":"PM2.5網頁","method":"GET","ret":"obj","url":"http://opendata.epa.gov.tw/ws/Data/REWIQA/?$orderby=SiteName&$skip=0&$top=1000&format=json","tls":"","x":370,"y":1120,"wires":[["82a51a3c.2b9db8","105817cf.499858"]]},{"id":"f8c4337f.45a23","type":"function","z":"23b81440.98563c","name":"設定地區","func":"var a = msg.payload;\n\na.forEach (function(e,i){ \n   if(e.SiteName == global.get('Location')) {\n        \n        msg.PM25 = ' PM2.5=' + e['PM2.5'] ;\n        msg.AQI = ' AQI=' + e['AQI'] ;\n        msg.Status = ' Status=' + e['Status'] ;\n        msg.PublishTime =' PublishTime='+ e['PublishTime'] ;\n        msg.payload=global.get('Location')+msg.PM25+msg.AQI+msg.Status+msg.PublishTime;\n\n        msg.PM251 =  e['PM2.5'] ;\n        msg.AQI1 =  e['AQI'] ;\n        msg.Status1 = e['Status'] ;\n        msg.PublishTime1 = e['PublishTime'] ;\n   }\n} );\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":1280,"wires":[["cf1424e7.947198","c2a9a9eb.30a1a8","bb27616d.7aadb","51a8cfa.23d693","d070af3b.5ebce","1bb6eab9.2a1885","d1d12bc3.9ec798","31b983ad.47a32c","d56ad1a5.38dd4"]]},{"id":"cf1424e7.947198","type":"debug","z":"23b81440.98563c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"PM25","x":650,"y":1320,"wires":[]},{"id":"c2a9a9eb.30a1a8","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"Status","x":650,"y":1280,"wires":[]},{"id":"bb27616d.7aadb","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"PublishTime","x":670,"y":1240,"wires":[]},{"id":"51a8cfa.23d693","type":"debug","z":"23b81440.98563c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"AQI","x":620,"y":1360,"wires":[]},{"id":"48fd93ee.37452c","type":"comment","z":"23b81440.98563c","name":"台灣空氣品質狀況","info":"","x":110,"y":1080,"wires":[]},{"id":"d070af3b.5ebce","type":"mqtt out","z":"23b81440.98563c","name":"空氣品質 AQI","topic":"alex9ufo/Dali/AQI","qos":"1","retain":"true","broker":"72a68059.89294","x":640,"y":1180,"wires":[]},{"id":"6c4bbbea.214ad4","type":"ui_gauge","z":"23b81440.98563c","name":"","group":"3281bbac.9f6944","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":810,"y":1400,"wires":[],"inputLabels":["msg.PM25"]},{"id":"2bdf9530.9de05a","type":"ui_text","z":"23b81440.98563c","group":"3281bbac.9f6944","order":0,"width":"6","height":"2","name":"","label":"空氣品質","format":"{{msg.payload}}","layout":"row-spread","x":720,"y":1520,"wires":[],"inputLabels":["msg.payload"]},{"id":"1bb6eab9.2a1885","type":"function","z":"23b81440.98563c","name":"PM2.5 [0..80]","func":"msg.payload=msg.PM251;\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":1400,"wires":[["6c4bbbea.214ad4"]]},{"id":"d1d12bc3.9ec798","type":"function","z":"23b81440.98563c","name":"AQI [0..400]","func":"msg.payload= msg.AQI1;\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":1460,"wires":[["365475f9.314e8a"]]},{"id":"365475f9.314e8a","type":"ui_gauge","z":"23b81440.98563c","name":"","group":"3281bbac.9f6944","order":0,"width":"6","height":"3","gtype":"gage","title":"AQI [0..50] 良好","label":"units","format":"{{value}}","min":0,"max":"400","colors":["#00b500","#e6e600","#ca3838"],"seg1":"50","seg2":"100","x":740,"y":1460,"wires":[],"inputLabels":["msg.PM25"]},{"id":"31b983ad.47a32c","type":"function","z":"23b81440.98563c","name":"Status","func":"msg.payload=msg.Status1;\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":1520,"wires":[["2bdf9530.9de05a"]]},{"id":"d56ad1a5.38dd4","type":"function","z":"23b81440.98563c","name":"PublishTime","func":"msg.payload=msg.PublishTime1;\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":1580,"wires":[["4a18a55e.4cf16c"]]},{"id":"4a18a55e.4cf16c","type":"ui_text","z":"23b81440.98563c","group":"3281bbac.9f6944","order":0,"width":"6","height":"3","name":"","label":"發表時間","format":"{{msg.payload}}","layout":"row-spread","x":720,"y":1580,"wires":[],"inputLabels":["msg.payload"]},{"id":"82a51a3c.2b9db8","type":"DataIn","z":"23b81440.98563c","collection":"be3d45fc.767ed8","name":"PM2.5","update":false,"path":"/myRootTest","x":590,"y":1100,"wires":[]},{"id":"d8ca9a21.15b7d8","type":"trigger","z":"23b81440.98563c","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":260,"y":1180,"wires":[["9b198a8.b2b9d78"]]},{"id":"9b198a8.b2b9d78","type":"DataOut","z":"23b81440.98563c","collection":"be3d45fc.767ed8","name":"PM2.5","path":"/myRootTest","error":false,"x":300,"y":1280,"wires":[["f8c4337f.45a23","5d86575d.5316a8"]]},{"id":"14f2e38b.fe207c","type":"function","z":"23b81440.98563c","name":"","func":"if (msg.payload===null)\n{\n    global.set('Location','大里');\n}\nelse\n{\n    global.set('Location',msg.payload);\n}\nnode.status({filee:\"green\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":150,"y":1280,"wires":[["9b198a8.b2b9d78"]]},{"id":"e38677fd.a67e68","type":"ui_dropdown","z":"23b81440.98563c","name":"","label":"","place":"Select option","group":"3281bbac.9f6944","order":0,"width":0,"height":0,"passthru":true,"options":[{"label":"大里","value":"大里","type":"str"},{"label":"二林","value":"二林","type":"str"},{"label":"板橋","value":"板橋","type":"str"},{"label":"士林","value":"士林","type":"str"},{"label":"南投","value":"南投","type":"str"}],"payload":"","topic":"","x":80,"y":1220,"wires":[["14f2e38b.fe207c"]]},{"id":"105817cf.499858","type":"debug","z":"23b81440.98563c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":1140,"wires":[]},{"id":"5d86575d.5316a8","type":"debug","z":"23b81440.98563c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":310,"y":1380,"wires":[]},{"id":"41c07aec.1d13f4","type":"mqtt-broker","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":15,"cleansession":true,"willQos":"0","birthQos":"0"},{"id":"6bcc7411.b1398c","type":"ui_group","z":"","name":"大里區空氣品質狀況","tab":"d1cb85f7.bd7098","order":1,"disp":true,"width":"6","collapse":false},{"id":"72a68059.89294","type":"mqtt-broker","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":15,"cleansession":true,"willQos":"0","birthQos":"0"},{"id":"3281bbac.9f6944","type":"ui_group","z":"","name":"空氣品質狀況","tab":"d1cb85f7.bd7098","order":1,"disp":true,"width":"6","collapse":false},{"id":"be3d45fc.767ed8","type":"json-db-collection","z":"","name":"DATA","collection":"DATA","save":false},{"id":"d1cb85f7.bd7098","type":"ui_tab","z":"","name":"AQI","icon":"dashboard","order":1}]

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...