2021年8月21日 星期六

台中市11站監控PM2.5 資料的擷取

 台中市11站監控PM2.5 資料的擷取










[{"id":"65f89fd1.062d1","type":"inject","z":"641a7946.ecd3e8","name":"Click","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"7200","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":80,"wires":[["4bafaf29.b7449"]]},{"id":"f20f4fe7.e943e","type":"ui_switch","z":"641a7946.ecd3e8","name":"","label":"啟動讀取opendata","tooltip":"","group":"9d7c6798.9fc5e8","order":61,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":110,"y":120,"wires":[["4bafaf29.b7449"]]},{"id":"2d21f576.7fbb0a","type":"ui_gauge","z":"641a7946.ecd3e8","name":"PM2.5","group":"9d7c6798.9fc5e8","order":62,"width":0,"height":0,"gtype":"gage","title":"細懸浮微粒(PM2.5)指標","label":"(μg/m3)","format":"{{value}}","min":0,"max":"71","colors":["#00b500","#e6e600","#ca3838"],"seg1":"35","seg2":"59","x":710,"y":280,"wires":[]},{"id":"4bafaf29.b7449","type":"http request","z":"641a7946.ecd3e8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://www.airq.org.tw/Home/realtime10m","tls":"","persist":false,"proxy":"","authType":"","x":300,"y":80,"wires":[["6f8f0a12.933724","d47c6d00.88d39"]]},{"id":"6f8f0a12.933724","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":80,"wires":[]},{"id":"94438361.32252","type":"function","z":"641a7946.ecd3e8","name":"找出  PM2.5  , PublishTime","func":"\nvar a = context.global.temp;\nvar b = msg.payload;\na.forEach(function(e,i){\n    if(e.Name==b)\n    {\n        msg.PM25 = e['Value'];\n        msg.PublishTime = e['StartTime'];\n    }\n});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":260,"wires":[["553bffe.3942d","783cb9d2.e15ec8","87486346.86b4b","a895a40c.f09148","bc465b0c.194938"]]},{"id":"553bffe.3942d","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"PM25","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":200,"wires":[]},{"id":"783cb9d2.e15ec8","type":"function","z":"641a7946.ecd3e8","name":"PM2.5資料","func":"msg.payload=msg.PM25;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":550,"y":280,"wires":[["2d21f576.7fbb0a","3893088c.bfcd08"]]},{"id":"3893088c.bfcd08","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":320,"wires":[]},{"id":"a4600dc9.fad98","type":"comment","z":"641a7946.ecd3e8","name":"PM2.5開放資料網址","info":"南投地區PM2.5開放資料網址如下:\n\nhttp://www.airq.org.tw/Home/AboutData_ZH\n\nJSON 格式 API(更新頻率:每 10分鐘)\n\nhttp://www.airq.org.tw/Home/realtime10m\n","x":110,"y":40,"wires":[]},{"id":"f032e2d9.9320b","type":"DataIn","z":"641a7946.ecd3e8","collection":"7a14aca8.b15994","name":"PM2.5","update":false,"path":"/","x":790,"y":180,"wires":[]},{"id":"d47c6d00.88d39","type":"function","z":"641a7946.ecd3e8","name":"set global temp","func":"context.global.temp=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":40,"wires":[[]]},{"id":"87486346.86b4b","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"PublishTime","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":240,"wires":[]},{"id":"6fe3827a.3f677c","type":"ui_text","z":"641a7946.ecd3e8","group":"9d7c6798.9fc5e8","order":63,"width":0,"height":0,"name":"發行時間","label":"發行時間","format":"{{msg.payload}}","layout":"row-center","x":720,"y":360,"wires":[]},{"id":"c13ae253.61b36","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":400,"wires":[]},{"id":"a895a40c.f09148","type":"function","z":"641a7946.ecd3e8","name":"發行時間","func":"msg.payload=msg.PublishTime;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":360,"wires":[["6fe3827a.3f677c","c13ae253.61b36"]]},{"id":"10b2caf3.2abdd5","type":"comment","z":"641a7946.ecd3e8","name":"","info":"https://www.ntepb.gov.tw/sub/content/index.aspx?Parser=1,17,511,494,496\n\n0-11\t12-23\t24-35\t\n低\t    低\t    低\n36-41\t42-47\t48-53\n中\t    中\t    中\n54-58   59-64\t65-70\t\n高\t    高\t    高\n>71\n非常高","x":530,"y":320,"wires":[]},{"id":"d413fad8.957c68","type":"change","z":"641a7946.ecd3e8","name":"","rules":[{"t":"set","p":"datapath","pt":"msg","to":"/myRootTest","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":160,"wires":[["f032e2d9.9320b","ed0f091c.c7a088"]]},{"id":"818e0e8a.dd2b7","type":"change","z":"641a7946.ecd3e8","name":"","rules":[{"t":"set","p":"datapath","pt":"msg","to":"/myRootTest","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":540,"wires":[["e74a4b8.c47f6b8"]]},{"id":"e74a4b8.c47f6b8","type":"DataOut","z":"641a7946.ecd3e8","collection":"7a14aca8.b15994","name":"PM2.5","path":"/","error":false,"x":530,"y":540,"wires":[["2ea0ef43.85641","d4a3893a.bf7d58"]]},{"id":"2ea0ef43.85641","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"console":"false","complete":"false","x":690,"y":480,"wires":[]},{"id":"c7b3dbcf.074cd8","type":"json","z":"641a7946.ecd3e8","name":"","property":"payload","action":"str","pretty":false,"x":450,"y":160,"wires":[["d413fad8.957c68","a4e6b49c.470298"]]},{"id":"a4e6b49c.470298","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":120,"wires":[]},{"id":"ed0f091c.c7a088","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":140,"wires":[]},{"id":"d4a3893a.bf7d58","type":"ui_text","z":"641a7946.ecd3e8","group":"9d7c6798.9fc5e8","order":6,"width":"0","height":"0","name":"","label":"PM2.5訊息","format":"{{msg.payload}}","layout":"row-center","x":710,"y":540,"wires":[]},{"id":"bc465b0c.194938","type":"function","z":"641a7946.ecd3e8","name":"PM2.5資料","func":"var s= context.global.school ;\n\nmsg.payload=[s,msg.PM25,msg.PublishTime];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":160,"wires":[["c7b3dbcf.074cd8"]]},{"id":"a403219a.298cc","type":"inject","z":"641a7946.ecd3e8","name":"Click","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"7200","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":540,"wires":[["818e0e8a.dd2b7"]]},{"id":"648674fa.217e4c","type":"ui_switch","z":"641a7946.ecd3e8","name":"","label":"啟動資料庫開關","tooltip":"","group":"9d7c6798.9fc5e8","order":61,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":100,"y":500,"wires":[["818e0e8a.dd2b7"]]},{"id":"57148a2e.67da14","type":"ui_dropdown","z":"641a7946.ecd3e8","name":"","label":"學校","tooltip":"","place":"請選擇","group":"9d7c6798.9fc5e8","order":0,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"雙十國中","value":"0","type":"str"},{"label":"東山高中","value":"1","type":"str"},{"label":"立新國中","value":"2","type":"str"},{"label":"大里高中","value":"3","type":"str"},{"label":"光德國中","value":"4","type":"str"},{"label":"和平國中","value":"5","type":"str"},{"label":"新社高中","value":"6","type":"str"},{"label":"神圳國中","value":"7","type":"str"},{"label":"大道國中","value":"8","type":"str"},{"label":"公明國中","value":"9","type":"str"},{"label":"清水高中","value":"10","type":"str"}],"payload":"","topic":"","x":350,"y":460,"wires":[["74fb744e.cdd70c"]]},{"id":"16389b5e.20d185","type":"inject","z":"641a7946.ecd3e8","name":"inject school  options","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"7200","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":140,"y":460,"wires":[["57148a2e.67da14","818e0e8a.dd2b7"]]},{"id":"9f3f3518.97af48","type":"debug","z":"641a7946.ecd3e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":350,"y":360,"wires":[]},{"id":"74fb744e.cdd70c","type":"function","z":"641a7946.ecd3e8","name":" number to name","func":"\nvar name=msg.payload;\nvar school=' ';\n\ntry {\n    \n   if(name== '0' )\n    {\n        school= '雙十國中';\n    }\n    \n    else if(name== '1' )\n    {\n        school= '東山高中';\n    }\n    \n     else if(name== '2' )\n    {\n        school= '立新國中';\n    }\n    else if(name== '3' )\n    {\n        school= '大里高中';\n    }\n    \n     else if(name== '4' )\n    {\n        school= '光德國中';\n    }\n    else if(name== '5' )\n    {\n        school= '和平國中';\n    }\n    \n     else if(name== '6' )\n    {\n        school= '新社高中';\n    }\n    else if(name== '7' )\n    {\n        school= '神圳國中';\n    }\n    \n     else if(name== '8' )\n    {\n        school= '大道國中';\n    }\n    else if(name== '9' )\n    {\n        school= '公明國中';\n    }\n    \n     else if(name== '10' )\n    {\n        school= '清水高中';\n    }\n\nelse  \n{\n     school= '大里高中';\n   \n}\n   \n   \n}\n\ncatch(err) {\n    school=\"大里高中\";\n}\n\n\n msg.payload= school;\n context.global.school=msg.payload;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":320,"wires":[["9f3f3518.97af48","94438361.32252"]]},{"id":"9d7c6798.9fc5e8","type":"ui_group","name":"台中PM2.5","tab":"89e51ea1.a64af","order":1,"disp":true,"width":"6","collapse":false},{"id":"7a14aca8.b15994","type":"json-db-collection","name":"DATA_PM25","collection":"DATA","save":false},{"id":"89e51ea1.a64af","type":"ui_tab","name":"Dashboard","icon":"dashboard"}]

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

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