跳到主要內容

透過Node-Red來撥放天氣預報TTS

1.去氣象資料開放平台註冊,並取得API授權碼

2.以下例子是取得新北市土城區未來一週天氣預報的API網址

https://opendata.cwb.gov.tw/dist/opendata-swagger.html?urls.primaryName=openAPI#/%E9%A0%90%E5%A0%B1/get_v1_rest_datastore_F_D0047_071



3.建立Node-Red,記得更新URL







Node-Red Code

[{"id":"de12f26a26ae775c","type":"tab","label":"流程4","disabled":false,"info":"","env":[]},{"id":"6b33595bc6a16e20","type":"inject","z":"de12f26a26ae775c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":200,"wires":[["540d0db5b62256fd"]]},{"id":"540d0db5b62256fd","type":"http request","z":"de12f26a26ae775c","name":"[天氣預報]-土城-HTTP","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://opendata.cwb.gov.tw/api/v1/rest/datastore/F-D0047-071?Authorization=授權碼&locationName=%E5%9C%9F%E5%9F%8E%E5%8D%80","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"User-Agent","valueType":"other","valueValue":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"}],"credentials":{},"x":380,"y":200,"wires":[["cbd12570f9ec2903"]]},{"id":"cbd12570f9ec2903","type":"function","z":"de12f26a26ae775c","name":"[天氣預報]-土城","func":"var message = \"土城今天\" + msg.payload.records.locations[0].location[0].weatherElement[10].time[0].elementValue[0].value;\n\nmsg.payload_tts = {\n    \"message\": message, \n    \"cache\": true,\n    \"options\": {\n        \"volume\": \"+50%\",\n        \"voice\": \"zh-TW-HsiaoChenNeural\",\n        \"pitch\": \"+0Hz\",\n        \"rate\": \"+0%\"\n    }\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":200,"wires":[["613eb8aff52cea98"]]},{"id":"613eb8aff52cea98","type":"api-call-service","z":"de12f26a26ae775c","name":"Homepod mini(客廳)","server":"b1fe2238.8c1ab","version":5,"debugenabled":false,"domain":"tts","service":"edge_tts_say","areaId":[],"deviceId":[],"entityId":["media_player.ke_ting"],"data":"msg.payload_tts","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":200,"wires":[[]]},{"id":"b1fe2238.8c1ab","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":true,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]


參考文章

Home assistant連接中央氣象局,讓Andriod TV當鬧鐘撥放氣象訊息

Json Parser Online

留言

這個網誌中的熱門文章

[經驗分享]開源IT資產管理系統 - Open-AudIT

企業營運必定與電腦系統脫離不了關係,每一部電腦散落在各部門、各辦公室,若是較具規模的公司,甚至會有跨好幾個地區的辦公室存在。 from Pocket http://ift.tt/2sI5nuB via IFTTT

RegistryChangesView 登錄檔比對工具,挖出某個設定修改了什麼..

在 Windows 電腦中,很多軟體在安裝/移除或執行時會在系統的「登錄檔」資料庫裡面加入、移除或修改許多項目,有些有修改是必須的,有些修改沒弄好的話可能會造成一些問題導致某些功能不正常或系統不穩定等等情況。 from Pocket http://ift.tt/2wiZCWi via IFTTT

Sonoff S31燒錄Tasmota

 1.線路連接 VCC<->3.3V RX<->TX TX<->RX GND<->GND #短路燒錄器上的3.3V 2.下載FTDI驅動程式,並安裝它 https://ftdichip.com/drivers/ 3.下載S31 Tasmota靭體 https://github.com/arendst/Tasmota/releases 4.下載ESPEasy燒錄軟體 https://github.com/letscontrolit/ESPEasy/releases 5.解壓縮ESPEasy,並把S31 Tasmota靭體(.bin)放到根目錄 6.按住S31上的reset鍵不放,插入USB後,維持5秒再放開 7.執行FlashESP8266.exe,並選取S31 Tasmota韌體(.bin) 8.燒錄成功後,看看wifi有沒有tasmota-xx-的WIFI SSID #Tasmota 12.2.0會遇到常常掉wifi的情形,可能跟Wifi 6 OFDMA、Mesh有關 https://github.com/tasmota/docs/blob/master/docs/FAQ.md https://tasmota.github.io/docs/FAQ/#device-disconnects-from-wi-fi-often