var rawdata =context.global.weather_records
var citynumber=rawdata.length;
var i;
var Temp1,Temp2,Temp3,Temp4,Temp5,Temp6;
var weather=[];
for (i=0; i<citynumber;i++)
{
Temp1=rawdata[i].locationName;
Temp2=rawdata[i].weatherElement[0].time[0].parameter.parameterName;
Temp3=rawdata[i].weatherElement[1].time[0].parameter.parameterName;
Temp4=rawdata[i].weatherElement[2].time[0].parameter.parameterName;
Temp5=rawdata[i].weatherElement[3].time[0].parameter.parameterName;
Temp6=rawdata[i].weatherElement[4].time[0].parameter.parameterName;
weather[i]=[Temp1,Temp2,Temp3,Temp4,Temp5,Temp6];
}
msg.payload=weather ;
return msg;
//Temp1=rawdata[i].weatherElement[0].time[0].parameter.parameterName;
===================================================
[{"id":"468f922801fa005a","type":"http request","z":"5b0443f33d97ce45","name":"今明36小時天氣預報","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://opendata.cwa.gov.tw/fileapi/v1/opendataapi/F-C0032-001?Authorization=CWB-40C25FFF-1224-4250-B9D9-3735AAE17DBF&downloadType=WEB&format=JSON","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":300,"y":120,"wires":[["254bac363b9f06a0","9f6d9a3d8fbc7a82","f48eec28efb890b5"]]},{"id":"254bac363b9f06a0","type":"debug","z":"5b0443f33d97ce45","name":"今明36小時天氣預報 message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":60,"wires":[]},{"id":"9f6d9a3d8fbc7a82","type":"function","z":"5b0443f33d97ce45","name":"今明36小時天氣預報 data process","func":"msg.payload=msg.payload.cwaopendata.dataset.location;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":140,"wires":[["288f6994b4ded07b","b107f043e23d2bd7"]]},{"id":"288f6994b4ded07b","type":"debug","z":"5b0443f33d97ce45","name":"UVI process message","active":true,"console":"false","complete":"payload","x":900,"y":140,"wires":[]},{"id":"f48eec28efb890b5","type":"function","z":"5b0443f33d97ce45","name":"Set context.global.36weather","func":"context.global.weather_records=msg.payload.cwaopendata.dataset.location;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":100,"wires":[[]]},{"id":"8ad8c198e4db7261","type":"ui_table","z":"5b0443f33d97ce45","group":"38f8f1c1d386a910","name":"未來8小時天氣預報","order":5,"width":10,"height":12,"columns":[],"outputs":0,"cts":false,"x":1030,"y":220,"wires":[]},{"id":"a2d89722898228ba","type":"ui_button","z":"5b0443f33d97ce45","name":"","group":"38f8f1c1d386a910","order":1,"width":4,"height":1,"passthru":false,"label":"取得未來8小時天氣預報","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":180,"wires":[["468f922801fa005a"]]},{"id":"b107f043e23d2bd7","type":"function","z":"5b0443f33d97ce45","name":"get All Sitename","func":"var rawdata =msg.payload;\nvar site_number=rawdata.length;\nvar site_array=[];\nvar i;\n\nfor (i=0; i<site_number;i++)\n{\n site_array[i]=rawdata[i].locationName;\n}\n\nmsg.payload=site_array;\n \nflow.set(\"weather_sitename\",site_array);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":200,"wires":[["67b3b04db85bd20f","e8c469f411a6e967"]]},{"id":"67b3b04db85bd20f","type":"debug","z":"5b0443f33d97ce45","name":"debug 248","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":200,"wires":[]},{"id":"e8c469f411a6e967","type":"change","z":"5b0443f33d97ce45","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":240,"wires":[["188de9a5f3485a9e"]]},{"id":"188de9a5f3485a9e","type":"ui_dropdown","z":"5b0443f33d97ce45","name":"","label":"今明36小時天氣預報","tooltip":"","place":"Select option","group":"38f8f1c1d386a910","order":3,"width":4,"height":1,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":540,"y":300,"wires":[["c6b7947c063a1699","8aece592f0df5fb1","dae0694d329b08cf"]]},{"id":"8aece592f0df5fb1","type":"debug","z":"5b0443f33d97ce45","name":"debug 249","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":340,"wires":[]},{"id":"1f7c9728f01d9286","type":"debug","z":"5b0443f33d97ce45","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":360,"wires":[]},{"id":"c6b7947c063a1699","type":"function","z":"5b0443f33d97ce45","name":"get 站名 今明36小時天氣預報","func":"var rawdata =context.global.weather_records;\nvar citynumber=rawdata.length;\nvar site_name=msg.payload;\n\nvar i;\nvar Temp1,Temp2,Temp3,Temp4;\n\n\nfor (i=0; i<citynumber;i++)\n\n{\n\n if (rawdata[i].locationName==site_name)\n\n {\n\n Temp1=rawdata[i].weatherElement[0].time[0].parameter.parameterName;\n\n Temp2=rawdata[i].weatherElement[0].time[0].startTime;\n\n Temp3=rawdata[i].weatherElement[0].time[0].endTime;\n\n Temp4= site_name + Temp1+ '--'+ '開始時間: '+ Temp2+ '結束時間: '+ Temp3;\n\n break;\n\n }\n\n}\n\nmsg.payload= Temp4;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":380,"wires":[["1f7c9728f01d9286","aee4a05fc573b83e"]]},{"id":"94908a98162d72ef","type":"inject","z":"5b0443f33d97ce45","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":100,"y":120,"wires":[["468f922801fa005a"]]},{"id":"dae0694d329b08cf","type":"function","z":"5b0443f33d97ce45","name":"get Sitename all records","func":"var rawdata =context.global.weather_records\n\nvar citynumber=rawdata.length;\n\nvar i;\nvar Temp1,Temp2,Temp3,Temp4,Temp5,Temp6;\n\nvar weather=[];\n\nfor (i=0; i<citynumber;i++)\n\n{\n Temp1=rawdata[i].locationName;\n Temp2=rawdata[i].weatherElement[0].time[0].parameter.parameterName;\n Temp3=rawdata[i].weatherElement[1].time[0].parameter.parameterName;\n Temp4=rawdata[i].weatherElement[2].time[0].parameter.parameterName; \n Temp5=rawdata[i].weatherElement[3].time[0].parameter.parameterName;\n Temp6=rawdata[i].weatherElement[4].time[0].parameter.parameterName; \n weather[i]=[Temp1,Temp2,Temp3,Temp4,Temp5,Temp6];\n}\n\nmsg.payload=weather ;\n\nreturn msg;\n\n//Temp1=rawdata[i].weatherElement[0].time[0].parameter.parameterName;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":260,"wires":[["8ad8c198e4db7261","34cdb065112c0a2a"]]},{"id":"34cdb065112c0a2a","type":"debug","z":"5b0443f33d97ce45","name":"debug 250","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1030,"y":300,"wires":[]},{"id":"2d6065e985a20843","type":"comment","z":"5b0443f33d97ce45","name":"一般天氣預報-今明36小時天氣預報","info":"一般天氣預報-今明36小時天氣預報","x":180,"y":40,"wires":[]},{"id":"aee4a05fc573b83e","type":"ui_text","z":"5b0443f33d97ce45","group":"38f8f1c1d386a910","order":4,"width":10,"height":1,"name":"","label":"未來8小時天氣","format":"{{msg.payload}}","layout":"row-spread","className":"","x":1060,"y":400,"wires":[]},{"id":"38f8f1c1d386a910","type":"ui_group","name":"Default","tab":"6571c5231932db28","order":2,"disp":true,"width":10,"collapse":false,"className":""},{"id":"6571c5231932db28","type":"ui_tab","name":"2024一般天氣預報","icon":"dashboard","disabled":false,"hidden":false}]
沒有留言:
張貼留言