2023年6月19日 星期一

實驗 用Line發送 OpenWeatherMap 天氣預報

 用LINE 發送天氣預報... - 修改 益師傅MQTT 與IoT 整合運用















[{"id":"fcb8cc8b.9a385","type":"json","z":"29e396d2.ea499a","name":"Data","property":"payload","action":"","pretty":true,"x":430,"y":260,"wires":[["68196c8e.5baf24","516d23d7.1715ac","ed094b3f.f695c8","8294e410.69c018","255eb1e.357024e","3c62cca0.3b2b74","721c1a.3b7583e8","d2405300.bc0c4"]]},{"id":"d2405300.bc0c4","type":"debug","z":"29e396d2.ea499a","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":540,"wires":[]},{"id":"68196c8e.5baf24","type":"ui_gauge","z":"29e396d2.ea499a","name":"","group":"ce9ab99a.e8a4d8","order":4,"width":4,"height":4,"gtype":"gage","title":"Temperature","label":"°C","format":"{{msg.payload.main.temp}}","min":"0","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":690,"y":240,"wires":[]},{"id":"516d23d7.1715ac","type":"ui_gauge","z":"29e396d2.ea499a","name":"","group":"ce9ab99a.e8a4d8","order":14,"width":4,"height":4,"gtype":"gage","title":"Pressure","label":"hPa","format":"{{msg.payload.main.pressure}}","min":"0","max":"2000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":680,"y":320,"wires":[]},{"id":"8294e410.69c018","type":"ui_gauge","z":"29e396d2.ea499a","name":"","group":"ce9ab99a.e8a4d8","order":13,"width":4,"height":4,"gtype":"gage","title":"Wind speed","label":"m/s","format":"{{msg.payload.wind.speed}}","min":"0","max":"40","colors":["#d4bdff","#b480f5","#9722f7"],"seg1":"","seg2":"","x":690,"y":400,"wires":[]},{"id":"10f264bc.bb973b","type":"http request","z":"29e396d2.ea499a","name":"Openweathermap","method":"GET","ret":"txt","paytoqs":"query","url":"http://api.openweathermap.org/data/2.5/weather?q={{{payload.city}}}&units=metric&appid=b3a1fd4de2403e47a564135a5be59821","tls":"","persist":false,"proxy":"","authType":"","x":470,"y":200,"wires":[["fcb8cc8b.9a385"]]},{"id":"ed094b3f.f695c8","type":"ui_gauge","z":"29e396d2.ea499a","name":"","group":"ce9ab99a.e8a4d8","order":12,"width":4,"height":4,"gtype":"gage","title":"Humidity","label":"%","format":"{{msg.payload.main.humidity}}","min":"0","max":"100","colors":["#a2d6f6","#8394ec","#1854e2"],"seg1":"","seg2":"","x":680,"y":360,"wires":[]},{"id":"255eb1e.357024e","type":"ui_gauge","z":"29e396d2.ea499a","name":"","group":"ce9ab99a.e8a4d8","order":5,"width":4,"height":4,"gtype":"gage","title":"max Temperature","label":"°C","format":"{{msg.payload.main.temp_max}}","min":"0","max":"40","colors":["#fdc9c9","#f37777","#f51919"],"seg1":"","seg2":"","x":710,"y":200,"wires":[]},{"id":"3c62cca0.3b2b74","type":"ui_gauge","z":"29e396d2.ea499a","name":"","group":"ce9ab99a.e8a4d8","order":6,"width":4,"height":4,"gtype":"gage","title":"mini Temperature","label":"°C","format":"{{msg.payload.main.temp_min}}","min":"0","max":"40","colors":["#b7f5b7","#00e639","#07c304"],"seg1":"","seg2":"","x":710,"y":280,"wires":[]},{"id":"49d1e5cd.bda8ac","type":"function","z":"29e396d2.ea499a","name":"WeatherIcon","func":"if (msg.payload == \"Mist\")\n  msg.payload = \"https://od.lk/s/MTVfMjQ4NjQwNDJf/w-16.jpg\"\nif (msg.payload == \"Clouds\")\n  msg.payload = \"https://od.lk/s/MTVfMjQ4NjQwNDJf/w-16.jpg\"\nif (msg.payload == \"Clear\")\n  msg.payload = \"https://od.lk/s/MTVfMjQ4NTU2ODdf/w-11.jpg\"\nif (msg.payload == \"Rain\")\n  msg.payload = \"https://od.lk/s/MTVfMjQ4NjQwNDBf/w-17.jpg\"\nif (msg.payload == \"Drizzle\")\n  msg.payload = \"https://od.lk/s/MTVfMjQ4NTU3MDJf/w-13.jpg\"\nif (msg.payload == \"Thunderstorm\")\n  msg.payload = \"https://od.lk/s/MTVfMjQ4NTU3NDBf/w-14.jpg\"  \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":400,"wires":[["ae1d8e92.f54f1"]]},{"id":"ae1d8e92.f54f1","type":"ui_template","z":"29e396d2.ea499a","group":"ce9ab99a.e8a4d8","name":"","order":3,"width":3,"height":4,"format":"\n \n <img width=\"60px\" height=\"60px\" src=  {{msg.payload}} alt='Image not found'  />\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":440,"y":480,"wires":[[]]},{"id":"721c1a.3b7583e8","type":"change","z":"29e396d2.ea499a","name":"Set Data","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.weather[0].main","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":320,"wires":[["49d1e5cd.bda8ac","aacafb2b145f7a56"]]},{"id":"cf7863d0.01071","type":"mqtt out","z":"29e396d2.ea499a","name":"Send Info","topic":"alex9ufo/TaiwanCW","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"841df58d.ee5e98","x":860,"y":460,"wires":[]},{"id":"3ccd1c33.cd5d04","type":"debug","z":"29e396d2.ea499a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":270,"y":340,"wires":[]},{"id":"8bfb631e.8030f","type":"ui_dropdown","z":"29e396d2.ea499a","name":"","label":"SelectCity","tooltip":"","place":"Select option","group":"ce9ab99a.e8a4d8","order":7,"width":4,"height":4,"passthru":true,"multiple":false,"options":[{"label":"台北","value":"Taipei","type":"str"},{"label":"基隆","value":"Keelung","type":"str"},{"label":"桃園","value":"Taoyuan","type":"str"},{"label":"苗栗","value":"Miaoli","type":"str"},{"label":"台中","value":"Taichung","type":"str"},{"label":"彰化","value":"Chang-hua","type":"str"},{"label":"南投","value":"Nantou","type":"str"},{"label":"雲林","value":"Douliu","type":"str"},{"label":"嘉義","value":"Chiayi City","type":"str"},{"label":"台南","value":"Tainan City","type":"str"},{"label":"高雄","value":"Kaohsiung City","type":"str"},{"label":"恆春","value":"Hengchun","type":"str"},{"label":"宜蘭","value":"Yilan","type":"str"},{"label":"花蓮","value":"Hualien City","type":"str"},{"label":"台東","value":"Taitung","type":"str"}],"payload":"","topic":"","topicType":"str","x":200,"y":140,"wires":[["e1fdc443.cfaad8"]]},{"id":"e1fdc443.cfaad8","type":"change","z":"29e396d2.ea499a","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.city","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":200,"wires":[["10f264bc.bb973b","25f1dd168eb7cf4a"]]},{"id":"d7111180.b7fce","type":"ui_template","z":"29e396d2.ea499a","group":"ce9ab99a.e8a4d8","name":"背景圖","order":5,"width":0,"height":0,"format":"<style>\n    body {\n        background-image: url(\"https://od.lk/s/MTVfMjYwMTkxODVf/weather_.jpg\");\n        background-size: 100% 100%;\n    }\n    \n    //body.nr-dashboard-theme md-content md-card {\n    //    background: rgba(1,200,1,0.1);\n    //}\n    \n   \n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":250,"y":460,"wires":[[]]},{"id":"b3fd8c4667b8b28d","type":"inject","z":"29e396d2.ea499a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":400,"wires":[["d7111180.b7fce"]]},{"id":"21a610922ab9cefe","type":"mqtt in","z":"29e396d2.ea499a","name":"Received Info","topic":"alex9ufo/TaiwanCW","qos":"2","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":620,"wires":[["2699d9962a00355f","f865355da7d64ebb"]]},{"id":"2699d9962a00355f","type":"function","z":"29e396d2.ea499a","name":"Format timestamp","func":"var date = new Date();\nvar h = date.getHours();\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n    h = '0'+h;\n}\nif(m<10){\n    m = '0' + m;\n}\nif(s<10){\n    s = '0' + s;\n}\nmsg.payload = msg.payload + ' --> Time:(' + h + ':' + m + ':' + s + ')' ;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":620,"wires":[["cf5b375d99909e98","43a4db1f801b7376"]]},{"id":"cf5b375d99909e98","type":"debug","z":"29e396d2.ea499a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":620,"wires":[]},{"id":"43a4db1f801b7376","type":"function","z":"29e396d2.ea499a","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer cnEzkvKQYNdsMGC3lbanLK41UoXg5fE2jAYBryJsYzdR'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":680,"wires":[["6826db832350394f"]]},{"id":"6826db832350394f","type":"http request","z":"29e396d2.ea499a","name":"","method":"POST","ret":"txt","url":"https://notify-api.line.me/api/notify","tls":"","x":640,"y":680,"wires":[["67dd7ef17ffe1d3c"]]},{"id":"67dd7ef17ffe1d3c","type":"debug","z":"29e396d2.ea499a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":680,"wires":[]},{"id":"f865355da7d64ebb","type":"debug","z":"29e396d2.ea499a","name":"debug 74","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":380,"y":560,"wires":[]},{"id":"aacafb2b145f7a56","type":"function","z":"29e396d2.ea499a","name":"function 19","func":"var msg3 = flow.get(\"location\");\nvar msg4='';\n\nvar msg1=msg.payload;\nvar msg2='';\n\nif (msg1 == \"Mist\")\n  msg2=\"薄霧\"\nif (msg1 == \"Clouds\")\n  msg2 = \"多雲\"\nif (msg1 == \"Clear\")\n  msg2 = \"晴朗\"\nif (msg1 == \"Rain\")\n  msg2= \"雨天\"\nif (msg1 == \"Drizzle\")\n  msg2 = \"細雨\"\nif (msg1 == \"Thunderstorm\")\n  msg2 = \"雷雨\"  \n\nif (msg3 == \"Miaoli\")\n  msg4=\"苗栗\"\nif (msg3 == \"Taipei\")\n  msg4 = \"台北\"\nif (msg3 == \"Keelung\")\n  msg4 = \"基隆\"\nif (msg3 == \"Taoyuan\")\n  msg4= \"桃園\"\n  \nif (msg3 == \"Taichung\")\n  msg4=\"台中\"\nif (msg3 == \"Chang-hua\")\n  msg4 = \"彰化\"\nif (msg3 == \"Nantou\")\n  msg4 = \"南投\"\nif (msg3 == \"Douliu\")\n  msg4= \"雲林斗六\"\n  \nif (msg3 == \"Chiayi City\")\n  msg4= \"嘉義市\"\nif (msg3 == \"Tainan City\")\n  msg4= \"台南市\"\nif (msg3 == \"Kaohsiung City\")\n  msg4= \"高雄市\"\nif (msg3 == \"Hengchun\")\n  msg4= \"恆春\"\nif (msg3 == \"Yilan\")\n  msg4= \"宜蘭\"\nif (msg3 == \"Hualien City\")\n  msg4= \"花蓮市\"\nif (msg3 == \"Taitung\")\n  msg4= \"台東\"\n\nmsg.payload = msg4+ ', 天氣狀況: '+msg2 ;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":460,"wires":[["cf7863d0.01071"]]},{"id":"25f1dd168eb7cf4a","type":"function","z":"29e396d2.ea499a","name":"function 20","func":"flow.set(\"location\",msg.payload.city);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":280,"wires":[["3ccd1c33.cd5d04"]]},{"id":"ce9ab99a.e8a4d8","type":"ui_group","name":"","tab":"d0721a70.d98a58","order":1,"disp":false,"width":"21","collapse":false},{"id":"841df58d.ee5e98","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"d0721a70.d98a58","type":"ui_tab","name":"OpenWeatherMap","icon":"dashboard","order":42,"disabled":false,"hidden":false}]

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...