2020年11月2日 星期一

OPEN Data 一般天氣預報-今明36小時天氣預報

 OPEN Data 一般天氣預報-今明36小時天氣預報 

https://opendata.cwb.gov.tw/dataset/forecast?page=26













Node-Red程式

[{"id":"e2a597f2.5a2028","type":"http request","z":"9e0666d0.5d85d8","name":"temp request","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://opendata.cwb.gov.tw/govdownload?dataid=F-C0032-001&authorizationkey=rdec-key-123-45678-011121314","tls":"","persist":false,"proxy":"","authType":"","x":290,"y":60,"wires":[["93225e9a.c5e85","8e7740ac.f38ae"]]},{"id":"3cab233d.9d39bc","type":"inject","z":"9e0666d0.5d85d8","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"7200","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":100,"y":40,"wires":[["e2a597f2.5a2028"]]},{"id":"93225e9a.c5e85","type":"debug","z":"9e0666d0.5d85d8","name":"temp request result","active":true,"console":"false","complete":"payload","x":489,"y":42,"wires":[]},{"id":"296f470e.a36b48","type":"debug","z":"9e0666d0.5d85d8","name":"xml to json","active":true,"console":"false","complete":"payload","x":585,"y":76,"wires":[]},{"id":"f1596a96.3702e8","type":"function","z":"9e0666d0.5d85d8","name":"set global temp","func":"\nglobal.set(\"tempera\",msg.payload); //global.set\nreturn msg;\n\n//flow.set('YourVariable', value);    // to store a variable (YourVariable)\n//var x = flow.get('YourVariable'); //to retrieve a variable (YourVariable)","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":120,"wires":[["b18aa7dc.97fa38"]]},{"id":"8e7740ac.f38ae","type":"xml","z":"9e0666d0.5d85d8","name":"","property":"payload","attr":"","chr":"","x":438,"y":100,"wires":[["f1596a96.3702e8","296f470e.a36b48"]]},{"id":"ebfbb129.bf4d9","type":"http in","z":"9e0666d0.5d85d8","name":"city","url":"/city","method":"get","upload":false,"swaggerDoc":"","x":84,"y":347,"wires":[["a9155ec8.9dfa8"]]},{"id":"26cd0e87.5ccee2","type":"http response","z":"9e0666d0.5d85d8","name":"http out","x":606,"y":347,"wires":[]},{"id":"a9155ec8.9dfa8","type":"function","z":"9e0666d0.5d85d8","name":"city name to number","func":"\nvar rawdata = flow.get(\"tempera\");\n\n//context.global.locationnumber=0;\nflow.set(\"locationnumber\",0);\ntry {\n   cityname=msg.payload.cityname;\n   \n   if(cityname.indexOf('台北')!=-1 ||cityname.indexOf('臺北')!=-1 )\n{\n    //context.global.locationnumber=0;\n    flow.set(\"locationnumber\",0);\n   \n}\nelse if(cityname.indexOf('新北')!=-1)\n{\n    //context.global.locationnumber=1;\n    flow.set(\"locationnumber\",1);\n}\nelse if(cityname.indexOf('桃園')!=-1) //\n{\n    //context.global.locationnumber=2;\n    flow.set(\"locationnumber\",2);\n}\nelse if(cityname.indexOf('臺中')!=-1 || cityname.indexOf('台中')!=-1) \n{\n    //context.global.locationnumber= 3;\n    flow.set(\"locationnumber\",3);\n}\nelse if(cityname.indexOf('臺南')!=-1 || cityname.indexOf('台南')!=-1) \n{\n    //context.global.locationnumber= 4;\n    flow.set(\"locationnumber\",4);\n   \n}\nelse if(cityname.indexOf('高雄')!=-1 ) \n{\n    //context.global.locationnumber= 5 ;\n    flow.set(\"locationnumber\",5);\n   \n}\nelse if(cityname.indexOf('基隆')!=-1 ) \n{\n    //context.global.locationnumber= 6 ;\n    flow.set(\"locationnumber\",6);\n}\nelse if(cityname.indexOf('新竹縣')!=-1 ) \n{\n    //context.global.locationnumber= 7 ;\n    flow.set(\"locationnumber\",7);\n}\nelse if(cityname.indexOf('新竹')!=-1 ) \n{\n    //context.global.locationnumber= 8 ;\n    flow.set(\"locationnumber\",8);\n}\nelse if(cityname.indexOf('新竹')!=-1 ) \n{\n    //context.global.locationnumber= 8 ;\n    flow.set(\"locationnumber\",8);\n}\nelse if(cityname.indexOf('苗栗')!=-1 ) \n{\n    //context.global.locationnumber= 9 ;\n    flow.set(\"locationnumber\",9);\n}\nelse if(cityname.indexOf('彰化')!=-1 ) \n{\n      flow.set(\"locationnumber\",10);\n}\nelse if(cityname.indexOf('南投')!=-1 ) \n{\n      flow.set(\"locationnumber\",11);\n}\nelse if(cityname.indexOf('雲林')!=-1 ) \n{\n      flow.set(\"locationnumber\",12);\n}\nelse if(cityname.indexOf('嘉義縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",13);\n}\nelse if(cityname.indexOf('嘉義市')!=-1 ) \n{\n      flow.set(\"locationnumber\",14);\n}\nelse if(cityname.indexOf('屏東')!=-1 ) \n{\n      flow.set(\"locationnumber\",15);\n}\nelse if(cityname.indexOf('宜蘭')!=-1 ) \n{\n      flow.set(\"locationnumber\",16);\n}\nelse if(cityname.indexOf('宜蘭')!=-1 ) \n{\n      flow.set(\"locationnumber\",16);\n}\nelse if(cityname.indexOf('花蓮')!=-1 ) \n{\n      flow.set(\"locationnumber\",17);\n}\nelse if(cityname.indexOf('臺東')!=-1 || cityname.indexOf('台東')!=-1)\n{\n      flow.set(\"locationnumber\",18);\n}\nelse if(cityname.indexOf('澎湖')!=-1 ) \n{\n      flow.set(\"locationnumber\",19);\n}\nelse if(cityname.indexOf('金門')!=-1 ) \n{\n      flow.set(\"locationnumber\",20);\n}\nelse if(cityname.indexOf('連江')!=-1 ) \n{\n    //context.global.locationnumber= 21 ;\n    flow.set(\"locationnumber\",21);\n}\nelse  \n{\n   // context.global.locationnumber= 0 ;\n    flow.set(\"locationnumber\",0);\n}\n   \n   \n}\ncatch(err) {\n    cityname=\"台北\";\n    //context.global.locationnumber=0;\n    flow.set(\"locationnumber\",0);\n}\n\nmsg.payload= flow.get(\"locationnumber\");\nreturn msg;\n","outputs":1,"noerr":0,"x":264,"y":347,"wires":[["b31b5479.d36c88","cd3e6364.df367"]]},{"id":"b31b5479.d36c88","type":"debug","z":"9e0666d0.5d85d8","name":"city name to number result","active":true,"console":"false","complete":"payload","x":520,"y":296,"wires":[]},{"id":"d2584f90.da37c","type":"http in","z":"9e0666d0.5d85d8","name":"tempjson","url":"/tempjson","method":"get","upload":false,"swaggerDoc":"","x":80,"y":160,"wires":[["b6bd4e75.0426a"]]},{"id":"5eb83680.9781c8","type":"http response","z":"9e0666d0.5d85d8","name":"http out","x":460,"y":160,"wires":[]},{"id":"b6bd4e75.0426a","type":"function","z":"9e0666d0.5d85d8","name":"show raw data","func":"//flow.set('YourVariable', value);    // to store a variable (YourVariable)\n//var x = flow.get('YourVariable'); //to retrieve a variable (YourVariable)\n//var loc=msg.payload.loc;\n\nvar rawdata = global.get(\"tempera\"); //global.get\n//msg.playload=rawdata.cwbopendata.dataset[0].location;\nmsg.payload=rawdata;\nreturn msg;\n\n/*\nmsg.payload = rawdata;\nreturn msg;\n*/\n\n//msg.playload=rawdata;\n//.cwbopendata.dataset[0].location;\n\n\n/*\nvar locationName=rawdata.cwbopendata.dataset[0].location[loc].locationName[0];\nvar period0max=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].parameter[0].parameterName[0];\nvar period0min=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[2].time[0].parameter[0].parameterName[0];\nvar period0start=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].startTime[0];\nvar period0end=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].endTime[0];\n\nvar  starthourtemp= period0start.split(\"T\");\nvar starthour=starthourtemp[1].split(\":\")[0];\nvar  endhourtemp= period0end.split(\"T\");\nvar endhour=endhourtemp[1].split(\":\")[0];\n\nmsg.payload={\"locationName\":locationName,\"time\":starthour+\"-\"+endhour, \"max\":period0max,\n\"min\":period0min};\nreturn msg;\n*/\n\n/*if(time.getHours()<18)\n{\nmsg.payload={\"locationName\":locationName,\"todaymax\":period1max, \"todaymin\":period1min,\n             \"tonightmax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\nelse\nmsg.payload={\"locationName\":locationName,\"tonightmax\":period1max, \"tonightmin\":period1min,\n             \"todaymax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\n\n*/\n\n\n\n\n//msg.payload=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[1];\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":260,"y":160,"wires":[["5eb83680.9781c8","ee08400c.2c901"]]},{"id":"ee08400c.2c901","type":"debug","z":"9e0666d0.5d85d8","name":"temp data process","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":200,"wires":[]},{"id":"88d691a1.3e90e","type":"function","z":"9e0666d0.5d85d8","name":"List locationname","func":"//var rawdata=context.global.temp;\nvar rawdata = flow.get(\"tempera\");\n//flow.set(\"loname\",rawdata.cwbopendata.dataset[0].location.locationName);\nvar location=rawdata.cwbopendata.dataset[0].location;\nvar citynumber=location.length;\nvar cityarray=[];\nvar i;\nfor (i=0; i<citynumber;i++)\n{\ncityarray[i]=location[i].locationName[0];\n}\n\n msg.payload=cityarray;\nflow.set(\"loname\",cityarray);\nreturn msg;\n\n/*\nvar locationName=rawdata.cwbopendata.dataset[0].location[loc].locationName[0];\nvar period0max=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].parameter[0].parameterName[0];\nvar period0min=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[2].time[0].parameter[0].parameterName[0];\nvar period0start=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].startTime[0];\nvar period0end=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].endTime[0];\n\nvar  starthourtemp= period0start.split(\"T\");\nvar starthour=starthourtemp[1].split(\":\")[0];\nvar  endhourtemp= period0end.split(\"T\");\nvar endhour=endhourtemp[1].split(\":\")[0];\n\nmsg.payload={\"locationName\":locationName,\"time\":starthour+\"-\"+endhour, \"max\":period0max,\n\"min\":period0min};\nreturn msg;\n*/\n\n/*if(time.getHours()<18)\n{\nmsg.payload={\"locationName\":locationName,\"todaymax\":period1max, \"todaymin\":period1min,\n             \"tonightmax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\nelse\nmsg.payload={\"locationName\":locationName,\"tonightmax\":period1max, \"tonightmin\":period1min,\n             \"todaymax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\n\n*/\n\n\n\n\n//msg.payload=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[1];\n\n\n\n\n","outputs":1,"noerr":0,"x":308,"y":255,"wires":[["f7bef722.c86c88"]]},{"id":"f7bef722.c86c88","type":"debug","z":"9e0666d0.5d85d8","name":"List all locationnames ","active":true,"console":"false","complete":"payload","x":527,"y":255,"wires":[]},{"id":"cd3e6364.df367","type":"function","z":"9e0666d0.5d85d8","name":"max min","func":"var loc=msg.payload;\nvar rawdata = flow.get(\"tempera\");\nvar locationName=rawdata.cwbopendata.dataset[0].location[loc].locationName[0];\nvar period0max=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].parameter[0].parameterName[0];\nvar period0min=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[2].time[0].parameter[0].parameterName[0];\nvar period0start=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].startTime[0];\nvar period0end=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].endTime[0];\n\nvar  starthourtemp= period0start.split(\"T\");\nvar starthour=starthourtemp[1].split(\":\")[0];\nvar  endhourtemp= period0end.split(\"T\");\nvar endhour=endhourtemp[1].split(\":\")[0];\n\nmsg.payload={\"locationName\":locationName,\"time\":starthour+\"-\"+endhour, \"max\":period0max,\n\"min\":period0min};\nreturn msg;\n\n/*if(time.getHours()<18)\n{\nmsg.payload={\"locationName\":locationName,\"todaymax\":period1max, \"todaymin\":period1min,\n             \"tonightmax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\nelse\nmsg.payload={\"locationName\":locationName,\"tonightmax\":period1max, \"tonightmin\":period1min,\n             \"todaymax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\n\n*/\n\n\n\n\n//msg.payload=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[1];\n\n\n\n\n","outputs":1,"noerr":0,"x":462,"y":347,"wires":[["26cd0e87.5ccee2"]]},{"id":"ec8ae7ac.285248","type":"debug","z":"9e0666d0.5d85d8","name":"report result","active":true,"console":"false","complete":"payload","x":670,"y":460,"wires":[]},{"id":"e90965f.3974498","type":"inject","z":"9e0666d0.5d85d8","name":"inject city options","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"7200","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":130,"y":420,"wires":[["11e741e8.e89aee"]]},{"id":"11e741e8.e89aee","type":"function","z":"9e0666d0.5d85d8","name":"set options","func":"var rawdata = flow.get(\"tempera\");\nvar location=rawdata.cwbopendata.dataset[0].location;\nvar citynumber=location.length;\nvar i;\n\nvar cityarray=[];\nfor (i=0; i<citynumber;i++)\n{\ncityarray[i]=location[i].locationName[0];\n\n\n}\nmsg.options=cityarray;\nreturn msg;\n\n/*\nvar locationName=rawdata.cwbopendata.dataset[0].location[loc].locationName[0];\nvar period0max=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].parameter[0].parameterName[0];\nvar period0min=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[2].time[0].parameter[0].parameterName[0];\nvar period0start=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].startTime[0];\nvar period0end=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].endTime[0];\n\nvar  starthourtemp= period0start.split(\"T\");\nvar starthour=starthourtemp[1].split(\":\")[0];\nvar  endhourtemp= period0end.split(\"T\");\nvar endhour=endhourtemp[1].split(\":\")[0];\n\nmsg.payload={\"locationName\":locationName,\"time\":starthour+\"-\"+endhour, \"max\":period0max,\n\"min\":period0min};\nreturn msg;\n*/\n\n/*if(time.getHours()<18)\n{\nmsg.payload={\"locationName\":locationName,\"todaymax\":period1max, \"todaymin\":period1min,\n             \"tonightmax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\nelse\nmsg.payload={\"locationName\":locationName,\"tonightmax\":period1max, \"tonightmin\":period1min,\n             \"todaymax\":period2max, \"tonightmin\":period2min,\"tomorrowmax\":period3max, \"tomorrowmin\":period3min};\n}\n\n*/\n\n\n\n\n//msg.payload=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[1];\n\n\n\n\n","outputs":1,"noerr":0,"x":310,"y":420,"wires":[["a18b45c8.73bea8","894c9f8e.3cd3a"]]},{"id":"70bc72e0.26993c","type":"inject","z":"9e0666d0.5d85d8","name":"inject city","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":108,"y":255,"wires":[["88d691a1.3e90e"]]},{"id":"517b0460.ee94cc","type":"function","z":"9e0666d0.5d85d8","name":"city to number","func":"\nvar cityname;\ncontext.global.locationnumber=0;\ntry {\n   cityname=msg.payload;\n   \n   if(cityname.indexOf('台北')!=-1 ||cityname.indexOf('臺北')!=-1 )\n{\n    context.global.locationnumber=0;\n   \n}\nelse if(cityname.indexOf('新北')!=-1)\n{\n    context.global.locationnumber=1;\n   \n}\nelse if(cityname.indexOf('桃園')!=-1) //\n{\n    context.global.locationnumber=2;\n   \n}\nelse if(cityname.indexOf('臺中')!=-1 || cityname.indexOf('台中')!=-1) \n{\n    context.global.locationnumber= 3;\n   \n}\nelse if(cityname.indexOf('臺南')!=-1 || cityname.indexOf('台南')!=-1) \n{\n    context.global.locationnumber= 4;\n   \n}\nelse if(cityname.indexOf('高雄')!=-1 ) \n{\n    context.global.locationnumber= 5 ;\n   \n}\nelse if(cityname.indexOf('基隆')!=-1 ) \n{\n    context.global.locationnumber= 6 ;\n   \n}\nelse if(cityname.indexOf('新竹縣')!=-1 ) \n{\n    context.global.locationnumber= 7 ;\n   \n}\nelse if(cityname.indexOf('新竹')!=-1 ) \n{\n    context.global.locationnumber= 8 ;\n   \n}\nelse if(cityname.indexOf('連江')!=-1 ) \n{\n    context.global.locationnumber= 21 ;\n   \n}\nelse  \n{\n    context.global.locationnumber= 0 ;\n   \n}\n   \n   \n}\ncatch(err) {\n    cityname=\"台北\";\n    context.global.locationnumber=0;\n}\n\n\n msg.payload= context.global.locationnumber;\nreturn msg;\n","outputs":1,"noerr":0,"x":320,"y":560,"wires":[[]]},{"id":"dc9079fa.d1aee8","type":"function","z":"9e0666d0.5d85d8","name":"report","func":"var loc=msg.payload;\n//var rawdata=context.global.temp;\nvar rawdata = flow.get(\"tempera\");\nvar locationName=rawdata.cwbopendata.dataset[0].location[loc].locationName[0];\nvar period0max=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].parameter[0].parameterName[0];\nvar period0min=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[2].time[0].parameter[0].parameterName[0];\nvar period0start=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].startTime[0];\nvar period0end=rawdata.cwbopendata.dataset[0].location[loc].weatherElement[1].time[0].endTime[0];\n\nvar  starthourtemp= period0start.split(\"T\");\nvar starthour=starthourtemp[1].split(\":\")[0];\nvar  endhourtemp= period0end.split(\"T\");\nvar endhour=endhourtemp[1].split(\":\")[0];\n\nmsg.payload=locationName+starthour+\"到\"+endhour+\"點溫度最低\"+period0min+\"度最高\"+period0max+\"度\";\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":500,"wires":[["ec8ae7ac.285248","fe250f8d.81b3"]]},{"id":"9911ba2a.5bf128","type":"debug","z":"9e0666d0.5d85d8","name":"selected city ","active":true,"tosidebar":true,"console":false,"complete":"payload","x":670,"y":420,"wires":[]},{"id":"a18b45c8.73bea8","type":"ui_dropdown","z":"9e0666d0.5d85d8","name":"","label":"city options","tooltip":"","place":"Select city","group":"31745d9a.412202","order":0,"width":0,"height":0,"passthru":true,"multiple":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":470,"y":420,"wires":[["9911ba2a.5bf128","facaa184.1e408"]]},{"id":"fe250f8d.81b3","type":"ui_text","z":"9e0666d0.5d85d8","group":"31745d9a.412202","order":0,"width":0,"height":0,"name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":650,"y":520,"wires":[]},{"id":"b18aa7dc.97fa38","type":"debug","z":"9e0666d0.5d85d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":120,"wires":[]},{"id":"894c9f8e.3cd3a","type":"debug","z":"9e0666d0.5d85d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"options","targetType":"msg","x":490,"y":380,"wires":[]},{"id":"facaa184.1e408","type":"function","z":"9e0666d0.5d85d8","name":"city name to number","func":"\nvar rawdata = flow.get(\"tempera\");\n\n//context.global.locationnumber=0;\nflow.set(\"locationnumber\",0);\ntry {\n   cityname=msg.payload;\n   \n   if(cityname.indexOf('台北市市')!=-1 ||cityname.indexOf('臺北市')!=-1 )\n{\n    //context.global.locationnumber=0;\n    flow.set(\"locationnumber\",0);\n   \n}\nelse if(cityname.indexOf('新北市')!=-1)\n{\n    //context.global.locationnumber=1;\n    flow.set(\"locationnumber\",1);\n}\nelse if(cityname.indexOf('桃園市')!=-1) //\n{\n    //context.global.locationnumber=2;\n    flow.set(\"locationnumber\",2);\n}\nelse if(cityname.indexOf('臺中市')!=-1 || cityname.indexOf('台中市')!=-1) \n{\n    //context.global.locationnumber= 3;\n    flow.set(\"locationnumber\",3);\n}\nelse if(cityname.indexOf('臺南市')!=-1 || cityname.indexOf('台南市')!=-1) \n{\n    //context.global.locationnumber= 4;\n    flow.set(\"locationnumber\",4);\n   \n}\nelse if(cityname.indexOf('高雄市')!=-1 ) \n{\n    //context.global.locationnumber= 5 ;\n    flow.set(\"locationnumber\",5);\n   \n}\nelse if(cityname.indexOf('基隆市')!=-1 ) \n{\n    //context.global.locationnumber= 6 ;\n    flow.set(\"locationnumber\",6);\n}\nelse if(cityname.indexOf('新竹縣')!=-1 ) \n{\n    //context.global.locationnumber= 7 ;\n    flow.set(\"locationnumber\",7);\n}\nelse if(cityname.indexOf('新竹市')!=-1 ) \n{\n    //context.global.locationnumber= 8 ;\n    flow.set(\"locationnumber\",8);\n}\nelse if(cityname.indexOf('苗栗縣')!=-1 ) \n{\n    //context.global.locationnumber= 9 ;\n    flow.set(\"locationnumber\",9);\n}\nelse if(cityname.indexOf('彰化縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",10);\n}\nelse if(cityname.indexOf('南投縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",11);\n}\nelse if(cityname.indexOf('雲林縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",12);\n}\nelse if(cityname.indexOf('嘉義縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",13);\n}\nelse if(cityname.indexOf('嘉義市')!=-1 ) \n{\n      flow.set(\"locationnumber\",14);\n}\nelse if(cityname.indexOf('屏東縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",15);\n}\nelse if(cityname.indexOf('宜蘭縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",16);\n}\nelse if(cityname.indexOf('花蓮縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",17);\n}\nelse if(cityname.indexOf('臺東縣')!=-1 || cityname.indexOf('台東縣')!=-1)\n{\n      flow.set(\"locationnumber\",18);\n}\nelse if(cityname.indexOf('澎湖縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",19);\n}\nelse if(cityname.indexOf('金門縣')!=-1 ) \n{\n      flow.set(\"locationnumber\",20);\n}\nelse if(cityname.indexOf('連江')!=-1 ) \n{\n    //context.global.locationnumber= 21 ;\n    flow.set(\"locationnumber\",21);\n}\nelse  \n{\n   // context.global.locationnumber= 0 ;\n    flow.set(\"locationnumber\",0);\n}\n   \n   \n}\ncatch(err) {\n    cityname=\"台北市\";\n    //context.global.locationnumber=0;\n    flow.set(\"locationnumber\",0);\n}\n\nmsg.payload= flow.get(\"locationnumber\");\nreturn msg;\n","outputs":1,"noerr":0,"x":320,"y":500,"wires":[["dc9079fa.d1aee8","c5fefb6d.2bfa38"]]},{"id":"c5fefb6d.2bfa38","type":"debug","z":"9e0666d0.5d85d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":560,"wires":[]},{"id":"ba78b990.fb2548","type":"ui_button","z":"9e0666d0.5d85d8","name":"","group":"31745d9a.412202","order":2,"width":0,"height":0,"passthru":false,"label":"START","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":120,"y":100,"wires":[["e2a597f2.5a2028"]]},{"id":"3187f9f1.fe0816","type":"ui_button","z":"9e0666d0.5d85d8","name":"","group":"31745d9a.412202","order":2,"width":0,"height":0,"passthru":false,"label":"Inject City","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":100,"y":300,"wires":[["88d691a1.3e90e"]]},{"id":"82e61f0e.cb58f","type":"ui_button","z":"9e0666d0.5d85d8","name":"","group":"31745d9a.412202","order":2,"width":0,"height":0,"passthru":false,"label":"Inject City Option","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":130,"y":460,"wires":[["11e741e8.e89aee"]]},{"id":"31745d9a.412202","type":"ui_group","z":"","name":"Default","tab":"1d173c13.e2dc64","order":1,"disp":true,"width":"6"},{"id":"1d173c13.e2dc64","type":"ui_tab","z":"","name":"Home","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...