"สวัสดีลุง Rock วันนี้วันอังคารที่ 18 พฤษภาคม 2021 ขณะนี้เวลา 13:02 และอุณหภูมิวันนี้ 34.2 องศาเซลเซียส พยากรณ์อากาศแจ้งว่าฝนปานกลางส่วนคุณภาพอากาศรอบบ้านดีมากค่ะ"
นี่คือคำพูดจากระบบ Google Assistant ผ่าน TTS หากมี Google Nest Mini ให้ทำการเชื่อมต่อเข้ากับ Home Assistant ให้ได้ก่อนจากนั้นค่อยเลือกให้ไปแจ้งเตือนที่ลำโพงแต่หากไม่มี ก็สามารถให้ไปพูดบนมือถือ Android ได้ทันที (เฉพาะเครื่องที่ลง Home Assistant)
สิ่งที่ต้องมี
Openweather Account สมัครให้เรียบร้อยและทำการสร้าง API รอไว้
Import Flow
ให้ Import Flow ทั้งหมดไปวาง และทำการแก้ไข
- Home Assistant Server
- Integration NodeRED Companion ให้ติดตั้งบน HACS จากนั้นไปที่ Home Asssistant Integrations เพิ่ม Integration Node-RED Companion ตามภาพ
- Weather Node
- Air Pollution Node
- TTS Mobile
Weather Node/Air Pollution ให้ทำการแก้ไข Lat/Long/API เป็นของตนเอง ส่วน TTS Mobile ให้เลือกมือถือ Android ที่จะส่ง TTS ไปพูด
[
{
"id": "119917d.62a4ce8",
"type": "tab",
"label": "JARVIS",
"disabled": false,
"info": ""
},
{
"id": "e445f6ad.850fc8",
"type": "inject",
"z": "119917d.62a4ce8",
"name": "Daily Report",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "00 09 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 140,
"wires": [
[
"88bfa7fc.8c5a98"
]
]
},
{
"id": "cd7c20a7.1050d",
"type": "simpletime",
"z": "119917d.62a4ce8",
"name": "DateTime",
"mydate": false,
"myymd": false,
"myyear": true,
"mymonth": true,
"mymonthn": false,
"mydom": true,
"mydoy": false,
"myday": true,
"myhourpm": false,
"myhour": false,
"mytime": true,
"mytimes": false,
"myminute": false,
"myminutes": false,
"mysecond": false,
"mymillis": false,
"myepoch": false,
"myrawdate": false,
"mypm": false,
"x": 700,
"y": 140,
"wires": [
[
"bc3a232a.4b88f"
]
]
},
{
"id": "bc3a232a.4b88f",
"type": "function",
"z": "119917d.62a4ce8",
"name": "",
"func": "if(msg.myday==\"Mon\"){\n msg.myday = \"วันจันทร์\"\n}\nif(msg.myday==\"Tue\"){\n msg.myday = \"วันอังคาร\"\n}\nif(msg.myday==\"Wed\"){\n msg.myday = \"วันพุธ\"\n}\nif(msg.myday==\"Thu\"){\n msg.myday = \"วันพฤหัสบดี\"\n}\nif(msg.myday==\"Fri\"){\n msg.myday = \"วันศุกร์\"\n}\nif(msg.myday==\"Sat\"){\n msg.myday = \"วันเสาร์\"\n}\nif(msg.myday==\"Sun\"){\n msg.myday = \"วันอาทิตย์\"\n}\nif(msg.mymonth==\"Jan\"){\n msg.mymonth = \"มกราคม\"\n}\nif(msg.mymonth==\"Feb\"){\n msg.mymonth = \"กุมภาพันธ์\"\n}\nif(msg.mymonth==\"Mar\"){\n msg.mymonth = \"มีนาคม\"\n}\nif(msg.mymonth==\"Apr\"){\n msg.mymonth = \"เมษายน\"\n}\nif(msg.mymonth==\"May\"){\n msg.mymonth = \"พฤษภาคม\"\n}\nif(msg.mymonth==\"Jun\"){\n msg.mymonth = \"มิถุนายน\"\n}\nif(msg.mymonth==\"Jul\"){\n msg.mymonth = \"กรกฎาคม\"\n}\nif(msg.mymonth==\"Aug\"){\n msg.mymonth = \"สิงหาคม\"\n}\nif(msg.mymonth==\"Sep\"){\n msg.mymonth = \"กันยายน\"\n}\nif(msg.mymonth==\"Oct\"){\n msg.mymonth = \"ตุลาคม\"\n}\nif(msg.mymonth==\"Nov\"){\n msg.mymonth = \"พฤศจิกายน\"\n}\nif(msg.mymonth==\"Dec\"){\n msg.mymonth = \"ธันวาคม\"\n}\n//Air Check\nvar air_chk;\nif(msg.aqi == 1){\n air_chk = \"คุณภาพอากาศรอบบ้านดีมากค่ะ\"\n}\nif(msg.aqi == 2){\n air_chk = \"คุณภาพอากาศรอบบ้านอยู่ในเกณฑ์ปกติค่ะ\"\n}\nif(msg.aqi == 3){\n air_chk = \"คุณภาพอากาศปานกลางค่ะ\"\n}\nif(msg.aqi == 4){\n air_chk =\"คุณภาพอากาศไม่ดีแนะนำให้ใส่หน้ากากป้องกันตลอดเวลาเมื่ออยู่นอกบ้านค่ะ\"\n}\nif(msg.aqi == 5){\n air_chk =\"คุณภาพอากาศโคตรแย่โปรดอยู่ในบ้านค่ะ\"\n}\nmsg.payload = \"สวัสดีลุงRock วันนี้\"+msg.myday+\"ที่\"+msg.mydom+msg.mymonth+msg.myyear+\"ขณะนี้เวลา\"+msg.mytime+\"และอุณหภูมิวันนี้\"+msg.temp+\"องศาเซลเซียส พยากรณ์อากาศแจ้งว่า\"+msg.weather+\"ส่วน\"+air_chk\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 840,
"y": 140,
"wires": [
[
"1112c388.e4301c"
]
]
},
{
"id": "1112c388.e4301c",
"type": "api-call-service",
"z": "119917d.62a4ce8",
"name": "TTS Mobile",
"server": "412771e3.2e1e2",
"version": 1,
"debugenabled": false,
"service_domain": "notify",
"service": "mobile_app_huawei_gr5",
"entityId": "",
"data": "{\"message\":\"TTS\",\"title\":msg.payload}",
"dataType": "jsonata",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 990,
"y": 140,
"wires": [
[]
]
},
{
"id": "c77a8228.8d06f",
"type": "www-request",
"z": "119917d.62a4ce8",
"name": "Air Pollution",
"method": "GET",
"ret": "obj",
"url": "http://api.openweathermap.org/data/2.5/air_pollution?lat=YOUR_LAT&lon=YOUR_LONG&appid=YOUR_API",
"follow-redirects": true,
"persistent-http": true,
"tls": "",
"x": 310,
"y": 200,
"wires": [
[
"8053d974.63f5b8"
]
]
},
{
"id": "73027bb9.bbe714",
"type": "change",
"z": "119917d.62a4ce8",
"name": "Weather",
"rules": [
{
"t": "set",
"p": "temp",
"pt": "msg",
"to": "payload.daily[0].temp.day",
"tot": "msg"
},
{
"t": "set",
"p": "weather",
"pt": "msg",
"to": "payload.daily[0].weather[0].description",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 440,
"y": 140,
"wires": [
[
"20f32651.1d3cfa"
]
]
},
{
"id": "88bfa7fc.8c5a98",
"type": "www-request",
"z": "119917d.62a4ce8",
"name": "Weather",
"method": "GET",
"ret": "obj",
"url": "https://api.openweathermap.org/data/2.5/onecall?lat=YOUR_LAT&lon=YOUR_LONG&units=metric&lang=th&appid=YOUR_API",
"follow-redirects": true,
"persistent-http": true,
"tls": "",
"x": 300,
"y": 140,
"wires": [
[
"73027bb9.bbe714"
]
]
},
{
"id": "d5f1b3e5.03855",
"type": "inject",
"z": "119917d.62a4ce8",
"name": "Get AQI",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "00 06 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 200,
"wires": [
[
"c77a8228.8d06f"
]
]
},
{
"id": "8053d974.63f5b8",
"type": "ha-entity",
"z": "119917d.62a4ce8",
"name": "OpenWeather AQI",
"server": "412771e3.2e1e2",
"version": 1,
"debugenabled": false,
"outputs": 1,
"entityType": "sensor",
"config": [
{
"property": "name",
"value": "OpenWeather AQI"
},
{
"property": "device_class",
"value": ""
},
{
"property": "icon",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
}
],
"state": "payload.list[0].main.aqi",
"stateType": "msg",
"attributes": [],
"resend": true,
"outputLocation": "",
"outputLocationType": "none",
"inputOverride": "allow",
"x": 530,
"y": 200,
"wires": [
[]
]
},
{
"id": "20f32651.1d3cfa",
"type": "api-current-state",
"z": "119917d.62a4ce8",
"name": "AQI",
"server": "412771e3.2e1e2",
"version": 1,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"override_topic": false,
"entity_id": "sensor.openweather_aqi",
"state_type": "str",
"state_location": "aqi",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"blockInputOverrides": false,
"x": 570,
"y": 140,
"wires": [
[
"cd7c20a7.1050d"
]
]
},
{
"id": "412771e3.2e1e2",
"type": "server",
"name": "NEW Home Assistant",
"legacy": false,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true
}
]