Skip to content

Home Assistant & Node Red Implementation of Waktu Solat Jakim using Azanpro

License

Notifications You must be signed in to change notification settings

anas-ivs/HA-NR-WaktuSolatJakim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HA-NR-WaktuSolatJakim

Waktu Solat (eSolat JAKIM) Home Assistant menggunakan Node Red. visitors

Flow Logik | Bagaimana ia berfungsi? | Pra-syarat | Pemasangan | Lovelace | Kredit |

Idea dan logik original perkongsian daripada komuniti Home Assistant Malaysia termasuk dari

  1. farxpeace yang menggunakan REST calls ke AzanPro API's.
  2. Zubir2K yang menggunakan REST call ke JAKIM eSolat API.
  3. Niezarm khusus bagi zone Hulu Langat.
  4. A Jim AI bagi link eSolat JSON API

Kelebihan menggunakan Node-Red untuk Waktu Solat ini termasuklah pengaturcaraan yang (jauh) lebih mudah berbanding pengaturcaraan YAML di dalam Home Assistant. Kelebihan ini membolehkan feature-feature asas dan tambahan seperti:

  1. Tarik (pull) dan simpanan data eSolat secara harian, mingguan/bulanan ataupun tahunan - bagi tempoh selain harian, ini membolehkan automation masih boleh berjalan jika API/server JAKIM down.
  2. Penghantaran Waktu Solat ke Home Assistant sebagai sensor untuk display di lovelace, ataupun untuk digunakan di dalam automations/scripts yang ditetapkan dari Home Assistant.
  3. Notifikasi melalui Telegram atau Home Assistant companion app secara push atau pull (demand).
  4. Membuat Notifikasi Waktu Solat termasuk;
    1. Notifikasi 15-minit sebelum waktu solat.
    2. Bagi 15-minit sebelum - Automation seperti play broadcast live Youtube Makkah atau Madinah feed ke chromecast devices. Sebagai tambahan, pemilihan stream boleh dibuat secara rawak.
    3. Menghidupkan TV melalui node Wake-on-LAN (WOL) supaya video azan dapat dimainkan.
    4. Pengumuman waktu menggunakan Google TTS ke speaker/chromecast devices.
    5. Membuat aturcaraan spesifik jika masuk waktu Solat Subuh seperti memainkan Azan Subuh.
    6. Penutupan TV secara automatik atau pembatalan penutupan TV melalui notifikasi ke Telefon.
  5. Trigger bagi menjalankan automation lain seperti membuka lampu luar dan menutup langsir 15 minit sebelum maghrib.
  6. Menentukan tempoh sekarang dan pengiraan tempoh waktu hingga ke Solat seterusnya.
  7. Tamabahan - Waktu Solat Node-Red dashboard. Credit to originator flow @aitalinassim

Node-Red Dashboard

Flow Logik

Logik flow sebenarnya disediakan di hujung sekali agar pembacaan berikut dibuat dahulu untuk memahami bagaimana ia berfungsi, apa yang perlu ditetapkan dan pra-syarat yang perlu dipenuhi.

Setiap bahagian di bawah akan menerangkan satu persatu bagaimana flow ini berfungsi berserta flow bagi bahagian tersebut. Adalah digalakkan untuk import flow logik secara kesuluruhan (di akhir) berbanding setiap bahagian berikut.

Jika sudah bersedia - bolehlah terus lompat terus ke sini

Bahagian 1 - Download Waktu Solat Bulanan

  1. Sebulan sekali, lebih tepat pada setiap 1hb bagi bulan tersebut, jam 1 pagi - Node cronplus akan membuat panggilan ke API eSolat JAKIM untuk mendapatkan waktu solat bagi bulan tersebut (terkini).
  2. Data yang diterima dalam bentuk json ini akan disimpan melalui Save to File ke file path /share/waktu_solat/waktu_solat_month.json.

PERHATIAN Lokasi ZONE hendaklah ditetapakan dahulu dalam node Solat API dan Zone. Ubah di line `zone_api = 'SWK02';

Rujukan bagi zone yang boleh dipakai boleh dirujuk sini.

Step1

[{"id":"928da9fc4f062354","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"c877b636.6a9488","type":"comment","z":"928da9fc4f062354","name":"Monthly Download","info":"### ## ### \n### ## ### additional nodes\n### ## ### \n### ## ### node-red-contrib-random-item \n# Via Cronjob","x":150,"y":60,"wires":[]},{"id":"545a4ddd.e0c3d4","type":"function","z":"928da9fc4f062354","name":"Solat API and Zone","func":"\n//Define ZONE here\n\nconst zone_api = 'SWK02';\n\n\nif (flow.get(\"waktu_solat_api\")===undefined)  {\n    \nflow.set(\"waktu_solat_api\", \"JAKIM\");\n}   \n\n//get global variable\nvar g = global.get(\"homeassistant\");\n//get states variable\nvar states = g.homeAssistant.states;\n//get the actual entity that we want\nvar waktu_solat_api = states[\"input_select.waktu_solat_api\"].state;\n\nflow.set(\"waktu_solat_api\", waktu_solat_api);\n\nmsg.waktu_solat_api = waktu_solat_api;\n\nif (waktu_solat_api == \"JAKIM\")\n{\nmsg.url = \"https://www.e-solat.gov.my/index.php?r=esolatApi%2Ftakwimsolat&period=month&zone=\"+zone_api;\n}\nelse if (waktusolat_source == \"AzanPro\")\n{\n    //not yet working use JAKIM\n    //msg.url = \"http://api.azanpro.com/times/today.json?zone=\"+zone_api+\"&format=24-hour\";\n    msg.url = \"https://www.e-solat.gov.my/index.php?r=esolatApi%2Ftakwimsolat&period=month&zone=\"+zone_api;\n\n}\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":220,"wires":[["1b8368da.094bc7"]]},{"id":"6037208e.54784","type":"inject","z":"928da9fc4f062354","name":"Tekan sekali untuk kali pertama","props":[],"repeat":"","crontab":"","once":false,"onceDelay":"0.1","topic":"","x":290,"y":160,"wires":[["545a4ddd.e0c3d4"]]},{"id":"17261447.7fa05c","type":"debug","z":"928da9fc4f062354","name":"bulanan","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1160,"y":100,"wires":[]},{"id":"1b8368da.094bc7","type":"http request","z":"928da9fc4f062354","name":"JAKIM","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":220,"wires":[["8cc47f84.fdc0f"]]},{"id":"b318b0c4.ff895","type":"file","z":"928da9fc4f062354","name":"Save to File","filename":"/share/waktu_solat/waktu_solat_month.json","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":990,"y":160,"wires":[["17261447.7fa05c","add6f5c.7a71b08"]]},{"id":"712b7fca.e8109","type":"cronplus","z":"928da9fc4f062354","name":"Monthly Refresh","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 1 1 * ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":160,"y":220,"wires":[["545a4ddd.e0c3d4"]]},{"id":"5b1dea78.548f44","type":"link in","z":"928da9fc4f062354","name":"i-trigger_solat_update","links":["effa5976.3108a8"],"x":335,"y":260,"wires":[["545a4ddd.e0c3d4"]]},{"id":"8cc47f84.fdc0f","type":"switch","z":"928da9fc4f062354","name":"QC","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":220,"wires":[["b318b0c4.ff895"],["bbf03c33.abaf9","55d5387a.1e6018"]]},{"id":"bbf03c33.abaf9","type":"debug","z":"928da9fc4f062354","name":"ERROR!","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1080,"y":220,"wires":[]},{"id":"780f0eb6.39ec5","type":"link out","z":"928da9fc4f062354","name":"O-TelegramP1","links":["8718a1dd.5beb7"],"x":1235,"y":300,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"add6f5c.7a71b08","type":"link out","z":"928da9fc4f062354","name":"o-trigger_solat_update","links":["45a9b7f2.cb00b8"],"x":1135,"y":160,"wires":[]},{"id":"12c47578.5297db","type":"telegram command","z":"928da9fc4f062354","name":"/refreshwaktusolat","command":"/refreshwaktusolat","description":"","registercommand":false,"language":"","bot":"","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":270,"y":100,"wires":[["545a4ddd.e0c3d4"],[]]},{"id":"c09e234b.c4258","type":"catch","z":"928da9fc4f062354","name":"","scope":["c89028ea.98f938","72b72987.9187c8","545a4ddd.e0c3d4","74e66f38.426cb","277ffb75.6e3b34","367f3e83.607102"],"uncaught":false,"x":830,"y":300,"wires":[["f4bf6ebd.84eee","bbf03c33.abaf9"]]},{"id":"f4bf6ebd.84eee","type":"template","z":"928da9fc4f062354","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"⚠️⚠️⚠️🕋 \nWaktu Solat Flow Error\nSource: {{error.source.name}}\n {{error.message}}","output":"str","x":1100,"y":300,"wires":[["780f0eb6.39ec5"]]},{"id":"55d5387a.1e6018","type":"template","z":"928da9fc4f062354","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"⚠️⚠️⚠️🕋 Data waktu solat bulan ini gagal untuk download dari {{waktu_solat_api}}\n\nError code: {{statusCode}}","output":"str","x":1100,"y":260,"wires":[["780f0eb6.39ec5"]]}]

Bahagian 2 - Baca dan tetapkan Waktu Solat Harian

  1. Sehari sekali, lebih tepat setiap hari jam 1 pagi - Node cronplus kali ini akan load waktu_solat_month.json yang telah disimpan sebelum ini di lokasi share/waktu_solat/

  2. Node Store Solat JAKIM to flow pula akan membuat beberapa perbandingan dan tetapan seperti:

    1. Load Waktu Solat bagi hari tersebut di dalam file waktu_solat_month.json.
    2. Membuat perbandingan jika data yang di-load adalah sah, melalui perbandingan jika bulan hari ini dan yang ditetapkan dalam fail adalah sama.
    3. Jika sah, dan waktu terkini selepas jam 8 malam - data waktu solat hari berikutnya akan diambil. Jika sebelum jam 8 malam, maka data Waktu Solat bagi hari tersebut akan diambil dan ditetapkan.
    4. Data Waktu Solat ini :
      1. Dihantar ke flow seterusnya sebagai sensor.waktu_solat untuk kegunaan Home Assistant.
      2. Disimpan di dalam Flow Context membolehkan node lain dalam Flow ini merujuk data ini.
    5. Data waktu Solat Jakim juga memberi tarikh Hijri - bulan (dalam digit) dipadankan dengan nama bulan bulan Islam. Logik asal membuat perkiraan sendiri melalui javascript yang telah dibuang dari flow ini.

    Step2

[{"id":"72b72987.9187c8","type":"function","z":"979d82cfea624e5f","name":"Store JAKIM SOLAT Data to Flow","func":"// Waktu Solat JAKIM\n// anas-ivs. 4th August 2021\n\nvar today           = new Date();\nvar dd              = String(today.getDate()).padStart(2, '0');\nvar mm              = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!\nvar yyyy            = today.getFullYear();\nvar current_time    = today.getHours();\ntoday               = mm + '/' + dd + '/' + yyyy;\n\n// data validity check :\nvar date_validation = msg.payload.prayerTime[dd-1].date.split(\"-\");\n\n// waktu_solat_hari_ini.date is in format DD-MONTH-YYYY. Month in Malay. Lookup array to match\nvar dict_bulan_bm   = [\"Januari\", \"Februari\", \"Mac\", \"April\", \"Mei\", \"Jun\", \"Julai\", \"Ogos\", \"September\", \"October\", \"November\", \"Disember\" ];\n\nif ( dd != date_validation[0] )\n{\n    msg.topic = \"ERROR\"\n    msg.payload =\"Gagal Data Validation - Hari tak padan\"\n    return msg;\n}\nif ( dict_bulan_bm[mm-1] != date_validation[1] )\n{\n    msg.topic = \"ERROR\"\n    msg.payload =\"Gagal Data Validation - Bulan tak sama\"\n    return msg;\n}\nif ( yyyy != date_validation[2] )\n{\n    msg.topic = \"ERROR\"\n    msg.payload =\"Gagal Data Validation - Tahun dah lain ni\"\n    return msg;\n}\n\n// debugging\n// msg.date_validation = date_validation;\n// msg.data_dd = dd;\n// msg.data_mm = mm;\n// msg.data_yyyy = yyyy;\n\nif (current_time >= 20) {\n    // first check if end of month - would be unable to load data.\n    // dd > array length from JSON\n    // what do we do? ideally load next month data but for now \n    // we ignore and wait for next month data fetch call up by CRON @ midnight\n    if (parseInt(dd) > msg.payload.prayerTime.length)\n    {\n        msg.waktu_solat_hari_ini  = msg.payload.prayerTime[dd-1];\n\n    }\n    else \n    {\n    // if after 8PM, then we get tomorrow's time and update HA\n        msg.waktu_solat_hari_ini  = msg.payload.prayerTime[parseInt(dd)];\n\n    }\n    \n} \nelse {\n    // retrieve from array (day - 1)\n    msg.waktu_solat_hari_ini  = msg.payload.prayerTime[dd-1];\n}\n\n//remove seconds\nmsg.waktu_solat_hari_ini.imsak      = msg.waktu_solat_hari_ini.imsak.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.fajr       = msg.waktu_solat_hari_ini.fajr.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.syuruk     = msg.waktu_solat_hari_ini.syuruk.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.dhuhr      = msg.waktu_solat_hari_ini.dhuhr.split(\":\").splice(0,2).join(\":\"); \nmsg.waktu_solat_hari_ini.asr        = msg.waktu_solat_hari_ini.asr.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.maghrib    = msg.waktu_solat_hari_ini.maghrib.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.isha       = msg.waktu_solat_hari_ini.isha.split(\":\").splice(0,2).join(\":\");\n\n\n// since JAKIM data provides tarik hijri - we use this instead\nvar jakim_hijri         = msg.waktu_solat_hari_ini.hijri.split(\"-\");\nvar dict_bulan_islam    = ['Muharram', 'Safar', 'Rabi\\' ul-awwal', 'Rabi\\' ul-akhir', 'Jumadil-awal', 'Jumadil-akhir', 'Rejab', 'Sha\\'aban', 'Ramadan', 'Shawwal', 'Zulkaedah', 'Zulhijjah'];\nmsg.hijri_date          = jakim_hijri[2]+\" \"+dict_bulan_islam[jakim_hijri[1] - 1]+\" \"+jakim_hijri[0]+\" H\";\n\n\n// for reference in Telegram notice\nmsg.waktu_solat_api =  flow.get(\"waktu_solat_api\");\nmsg.waktu_solat_hari_ini.zone                   = msg.payload.zone;\nmsg.waktu_solat_hari_ini.data_download_date     = msg.payload.serverTime;\n\n// Store in Flow\nflow.set(\"zone\", msg.waktu_solat_hari_ini.zone);\nflow.set(\"data_download_date\", msg.waktu_solat_hari_ini.data_download_date);\nflow.set(\"waktu_imsak\", msg.waktu_solat_hari_ini.imsak);\nflow.set(\"waktu_subuh\", msg.waktu_solat_hari_ini.fajr);\nflow.set(\"waktu_syuruk\", msg.waktu_solat_hari_ini.syuruk);\nflow.set(\"waktu_zohor\", msg.waktu_solat_hari_ini.dhuhr);\nflow.set(\"waktu_asar\", msg.waktu_solat_hari_ini.asr);\nflow.set(\"waktu_maghrib\", msg.waktu_solat_hari_ini.maghrib);\nflow.set(\"waktu_isyak\", msg.waktu_solat_hari_ini.isha);\nflow.set(\"waktu_tarikh_hari\", msg.waktu_solat_hari_ini.day);\nflow.set(\"waktu_tarikh_hijri\", msg.waktu_solat_hari_ini.hijri);\nflow.set(\"waktu_tarikh_masihi\", msg.waktu_solat_hari_ini.date);\n\n//if manage to get this far meaning data is available.\n//filter topic = validated only to proceed and update solat registers\nmsg.topic = \"OK\"\n\nreturn msg;\n\n      ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":340,"wires":[["44fe01b1.351e6","89f062ef.b3e0c"]]},{"id":"cac2e18d.0473a","type":"comment","z":"979d82cfea624e5f","name":"Daily Lookup and Load into Flow","info":"### ## ### \n### ## ### additional nodes\n### ## ### \n### ## ### node-red-contrib-random-item \n# Via Cronjob","x":130,"y":240,"wires":[]},{"id":"a2e493b6.db17e","type":"inject","z":"979d82cfea624e5f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"1","payloadType":"num","x":250,"y":300,"wires":[["eaabfff6.c4fca"]]},{"id":"eaabfff6.c4fca","type":"file in","z":"979d82cfea624e5f","name":"Retreive from File","filename":"/share/waktu_solat/waktu_solat_month.json","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":470,"y":340,"wires":[["14c50ab9.ffc0b5"]]},{"id":"14c50ab9.ffc0b5","type":"json","z":"979d82cfea624e5f","name":"","property":"payload","action":"","pretty":false,"x":650,"y":340,"wires":[["72b72987.9187c8"]]},{"id":"89f062ef.b3e0c","type":"debug","z":"979d82cfea624e5f","name":"harian","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":400,"wires":[]},{"id":"f4cefcd7.e6dc7","type":"delay","z":"979d82cfea624e5f","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":275,"y":420,"wires":[["eaabfff6.c4fca"]],"l":false},{"id":"45a9b7f2.cb00b8","type":"link in","z":"979d82cfea624e5f","name":"i-trigger_solat_update","links":["add6f5c.7a71b08"],"x":215,"y":420,"wires":[["f4cefcd7.e6dc7"]]},{"id":"b3129f3.663f26","type":"cronplus","z":"979d82cfea624e5f","name":"Daily Refresh - 6 Hourly","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 1 * * ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":130,"y":340,"wires":[["eaabfff6.c4fca"]]},{"id":"f14bd617.555d38","type":"link out","z":"979d82cfea624e5f","name":"T-Covid","links":["8718a1dd.5beb7"],"x":995,"y":520,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"f1d9ff16.648c7","type":"template","z":"979d82cfea624e5f","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"🕋 Waktu Solat bagi zon {{ waktu_solat_hari_ini.zone }} \nTarikh: {{ hijri_date }} \n{{ waktu_solat_hari_ini.date }}\n\n*Imsak*  : {{ waktu_solat_hari_ini.imsak}}\n*Subuh*  : {{ waktu_solat_hari_ini.fajr }}\n*Syuruk* : {{ waktu_solat_hari_ini.syuruk }}\n*Zohor*  : {{ waktu_solat_hari_ini.dhuhr }}\n*Asar*   : {{ waktu_solat_hari_ini.asr}}\n*Maghrib*: {{ waktu_solat_hari_ini.maghrib }}\n*Isyak*  : {{ waktu_solat_hari_ini.isha }}\n\nData download date: {{waktu_solat_hari_ini.data_download_date}}\n\n\n","output":"str","x":860,"y":520,"wires":[["f14bd617.555d38"]]},{"id":"1fa6ec3f.49e3a4","type":"switch","z":"979d82cfea624e5f","name":"","property":"telegramrequest","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":710,"y":520,"wires":[["f1d9ff16.648c7"]]},{"id":"587e7b3c.00bad4","type":"telegram command","z":"979d82cfea624e5f","name":"/getwaktusolat","command":"/getwaktusolat","description":"","registercommand":false,"language":"","bot":"","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":150,"y":500,"wires":[["4d33a0ca.1a43a"],[]]},{"id":"71fe748c.fce81c","type":"link in","z":"979d82cfea624e5f","name":"T-BroadcastWaktuSolat","links":["f80100ac.269b"],"x":120,"y":580,"wires":[["4d33a0ca.1a43a"]],"l":true},{"id":"4d33a0ca.1a43a","type":"change","z":"979d82cfea624e5f","name":"Telegram flag","rules":[{"t":"set","p":"telegramrequest","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":540,"wires":[["eaabfff6.c4fca"]]},{"id":"780f0eb6.39ec5","type":"link out","z":"979d82cfea624e5f","name":"O-TelegramP1","links":["8718a1dd.5beb7"],"x":1175,"y":240,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"44fe01b1.351e6","type":"switch","z":"979d82cfea624e5f","name":"QC","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"ERROR","vt":"str"},{"t":"eq","v":"OK","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1130,"y":340,"wires":[["defed156.ef28d"],["7a213032.e050d","78231aab.c50324","42ec6eeb.68c1e","4c277dfb.098854","86133ba6.a8d9f8","8475476f.84bdc8","ec295e23.a85c7","a6f28b9d.b65af8","c8023b05.eb95b8","ffbb9922.968248","1fa6ec3f.49e3a4"]]},{"id":"defed156.ef28d","type":"template","z":"979d82cfea624e5f","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"⚠️⚠️⚠️🕋 Data waktu solat hari ini gagal ditetapkan. \n\nSebabnya {{payload}}","output":"str","x":1040,"y":280,"wires":[["780f0eb6.39ec5"]]},{"id":"621aaea6.50ac3","type":"group","z":"979d82cfea624e5f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["371ec913.5f6726","86133ba6.a8d9f8","4c277dfb.098854","a8edf8c6.0ac928","f8af1838.d32f78","8870a7b0.dc6df8","4a67e276.26637c","79962577.886d2c","8475476f.84bdc8","ec295e23.a85c7","a6f28b9d.b65af8","c8023b05.eb95b8","ffbb9922.968248","42ec6eeb.68c1e","6f51f1a4.9d5fb","78231aab.c50324","1b2f2219.a0563e","7a213032.e050d","8c7b13db.5de7c","5ca1cb56.9a8594"],"x":1364,"y":159,"w":532,"h":662},{"id":"371ec913.5f6726","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":2,"width":0,"height":0,"name":"","label":"Subuh ","format":"{{msg.payload.prayer_times.subuh}}","layout":"row-spread","x":1750,"y":420,"wires":[]},{"id":"86133ba6.a8d9f8","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"Subuh_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Subuh"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.fajr","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1500,"y":420,"wires":[["371ec913.5f6726"]]},{"id":"4c277dfb.098854","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"WaktuSolat_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Waktu Solat"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"hijri_date","stateType":"msg","attributes":[{"property":"Subuh","value":"waktu_solat_hari_ini.fajr","valueType":"msg"},{"property":"Syuruk","value":"waktu_solat_hari_ini.syuruk","valueType":"msg"},{"property":"Zohor","value":"waktu_solat_hari_ini.dhuhr","valueType":"msg"},{"property":"Asar","value":"waktu_solat_hari_ini.asr","valueType":"msg"},{"property":"Maghrib","value":"waktu_solat_hari_ini.maghrib","valueType":"msg"},{"property":"Isyak","value":"waktu_solat_hari_ini.isha","valueType":"msg"},{"property":"Zone","value":"waktu_solat_hari_ini.zone","valueType":"msg"},{"property":"Tarikh","value":"waktu_solat_hari_ini.date","valueType":"msg"},{"property":"Data Downloaded Date","value":"waktu_solat_hari_ini.data_download_date","valueType":"msg"},{"property":"API Source","value":"waktu_solat_api","valueType":"msg"},{"property":"Imsak","value":"waktu_solat_hari_ini.imsak","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1520,"y":360,"wires":[[]]},{"id":"a8edf8c6.0ac928","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":3,"width":0,"height":0,"name":"","label":"Syuruk","format":"{{msg.payload.prayer_times.syuruk}}","layout":"row-spread","x":1740,"y":480,"wires":[]},{"id":"f8af1838.d32f78","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":4,"width":0,"height":0,"name":"","label":"Zohor","format":"{{msg.payload.prayer_times.zohor}}","layout":"row-spread","x":1750,"y":540,"wires":[]},{"id":"8870a7b0.dc6df8","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":5,"width":0,"height":0,"name":"","label":"Asar","format":"{{msg.payload.prayer_times.asar}}","layout":"row-spread","x":1750,"y":600,"wires":[]},{"id":"4a67e276.26637c","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":6,"width":0,"height":0,"name":"","label":"Maghrib","format":"{{msg.payload.prayer_times.maghrib}}","layout":"row-spread","x":1740,"y":660,"wires":[]},{"id":"79962577.886d2c","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":7,"width":0,"height":0,"name":"","label":"Isyak","format":"{{msg.payload.prayer_times.isyak}}","layout":"row-spread","x":1750,"y":720,"wires":[]},{"id":"8475476f.84bdc8","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"Syuruk_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Syuruk"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.syuruk","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1500,"y":480,"wires":[["a8edf8c6.0ac928"]]},{"id":"ec295e23.a85c7","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"Zohor_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Zohor"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.dhuhr","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1500,"y":540,"wires":[["f8af1838.d32f78"]]},{"id":"a6f28b9d.b65af8","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"Asar_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Asar"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.asr","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1500,"y":600,"wires":[["8870a7b0.dc6df8"]]},{"id":"c8023b05.eb95b8","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"Maghrib_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Maghrib"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.maghrib","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1510,"y":660,"wires":[["4a67e276.26637c"]]},{"id":"ffbb9922.968248","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"Isyak_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Isyak"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.isha","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1500,"y":720,"wires":[["79962577.886d2c"]]},{"id":"42ec6eeb.68c1e","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"ZoneWaktuSolat_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Zone Waktu Solat"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:home-map-marker"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.zone","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1530,"y":300,"wires":[["6f51f1a4.9d5fb"]]},{"id":"6f51f1a4.9d5fb","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":1,"width":0,"height":0,"name":"","label":"Zone","format":"{{msg.payload.zone}}","layout":"row-spread","x":1750,"y":300,"wires":[]},{"id":"78231aab.c50324","type":"ha-entity","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"TarikhWaktuSolat_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Tarikh Waktu Solat"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.date","stateType":"msg","attributes":[],"resend":false,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1540,"y":240,"wires":[["1b2f2219.a0563e"]]},{"id":"1b2f2219.a0563e","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":1,"width":0,"height":0,"name":"","label":"Date ","format":"{{msg.payload.prayer_times.date}}","layout":"row-spread","x":1750,"y":240,"wires":[]},{"id":"7a213032.e050d","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":1,"width":0,"height":0,"name":"","label":"Datestamp","format":"{{msg.payload.prayer_times.datestamp}}","layout":"row-spread","x":1470,"y":200,"wires":[]},{"id":"8c7b13db.5de7c","type":"ui_text","z":"979d82cfea624e5f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":5,"width":0,"height":0,"name":"","label":"HASS Current Time","format":"{{msg.payload}}","layout":"row-spread","x":1790,"y":780,"wires":[]},{"id":"5ca1cb56.9a8594","type":"server-state-changed","z":"979d82cfea624e5f","g":"621aaea6.50ac3","name":"time now","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.time","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":1460,"y":780,"wires":[["8c7b13db.5de7c"]]}]

Bahagian 3 - Bandingkan waktu terkini dan waktu Solat

  1. Setiap minit, melalui inject - node function - Compare times akan dijalankan . Blok ini akan:
    1. Load Waktu Solat melalui Flow Node-Red Context yang telah disimpan sebelum ini.
    2. Mengambil tarikh dan jam terkini dari system.
    3. Menentukan tempoh Waktu solat sekarang, Waktu solat berikutnya dan tempoh masa yang tinggal.
    4. Menentukan jika sudah masuk Waktu Solat.
  2. Setiap minit - jika belum masuk (5+2) Waktu Solat ; output function block ini akan mengemaskini tempoh masa terkini ke solat seterusnya.
  3. Jika sudah masuk Solat - Waktu solat akan ditetapkan melalui msg.waktu_solat.
  4. Node switch digunakan untuk membuat tetapan spesifik yang hendak dibuat bagi setiap (5+2 : Imsak, Syuruk) Waktu Solat.

Step3

[{"id":"7a8ff58b.91c62c","type":"group","z":"979d82cfea624e5f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["1c81239f.dfd61c","fda63eeb.b7931","e79ae7ad.22ab78","2dee4275.f2107e","cdc3643e.25f498","208d52d.827ddae","1b55833e.01921d","124eef07.c54df1","728a09a9.c18338","746147b6.de9f68","8b88caa3.9776d8","29ac26b3.c2dc6a","edaa6b5e.0aa918","e9044ba9.d82468","db1127cc.ff45f8","799108f0.41bb28","a6f0b09e.7dfd2","277ffb75.6e3b34","4945c457.ae3a2c","4541b1d8.57bc5","73dbc05.7ae684","e7de13f9.4c83f","b82459be.056f48","511b9079.f8fcb","ea4e5db9.99087","8f54ce9.8394b3","c25108a8.993cc8","e9044ba9.d82468"],"x":174,"y":79,"w":1702,"h":442},{"id":"1c81239f.dfd61c","type":"switch","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Solat Spesific Commands","property":"waktu_solat","propertyType":"msg","rules":[{"t":"eq","v":"Subuh","vt":"str"},{"t":"eq","v":"Syuruk","vt":"str"},{"t":"eq","v":"Zohor","vt":"str"},{"t":"eq","v":"Asar","vt":"str"},{"t":"eq","v":"Maghrib","vt":"str"},{"t":"eq","v":"Isyak","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":390,"y":440,"wires":[["fda63eeb.b7931","2dee4275.f2107e"],["e79ae7ad.22ab78"],["fda63eeb.b7931"],["fda63eeb.b7931"],["fda63eeb.b7931","1b55833e.01921d"],["fda63eeb.b7931"]]},{"id":"fda63eeb.b7931","type":"change","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Craft Message","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"🕌 Kini telah masuk waktu solat \" & $.waktu_solat","tot":"jsonata"},{"t":"set","p":"data","pt":"msg","to":"$.payload ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":320,"wires":[["e9044ba9.d82468","799108f0.41bb28","a6f0b09e.7dfd2","b82459be.056f48"]]},{"id":"e79ae7ad.22ab78","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Syuruk","links":["44aaf8a8.5112c8"],"x":770,"y":440,"wires":[],"l":true},{"id":"2dee4275.f2107e","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Subuh","links":["3c0048b4.36eee8"],"x":770,"y":400,"wires":[],"l":true},{"id":"cdc3643e.25f498","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"T-Waktu Solat","links":["8718a1dd.5beb7"],"x":1215,"y":200,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"208d52d.827ddae","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"WS Speaker Out - TTS","links":["c4134f1d.de9a5"],"x":1215,"y":320,"wires":[],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"1b55833e.01921d","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Maghrib","links":["8a34191d.af0b48","b674ddb2.4b5f7","dd2fe950.30acf8"],"x":780,"y":480,"wires":[],"l":true},{"id":"124eef07.c54df1","type":"delay","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"45","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1260,"y":380,"wires":[["728a09a9.c18338"]]},{"id":"728a09a9.c18338","type":"api-call-service","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"TTS","server":"","version":3,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.chromecast","data":"{\"message\":\"{{payload}}\",\"cache\":\"true\",\"language\":\"id\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"payload","valueType":"msg"}],"queue":"none","x":1410,"y":380,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini1.svg"},{"id":"746147b6.de9f68","type":"debug","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"SolatTimes","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":200,"wires":[]},{"id":"8b88caa3.9776d8","type":"ha-entity","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Time to next prayer","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"solat_bakiwaktu"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"time_waktuberikut","stateType":"msg","attributes":[{"property":"Waktu Solat Sekarang","value":"waktu_solat_sekarang","valueType":"msg"},{"property":"Waktu Solat Berikut","value":"waktu_solat_berikut","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":690,"y":260,"wires":[[]]},{"id":"29ac26b3.c2dc6a","type":"function","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Youtube/Azan Random","func":"let playlist_random = getRndInteger(1,6);\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\nswitch (playlist_random) {\n    case(1):\n        videoid = \"6IyJWdsbbYs\";\n        break;\n    case(2):\n        videoid = \"T7s3IFMktLo\";\n        break;\n    case(3):\n        videoid = \"vXQhE2CMhhM\";\n        break;\n    case(4):\n        videoid = \"my-IGBTNnYE\";\n        break;\n    case(5):\n        videoid = \"DdC7R3s7eCY\";\n        break\n    case(6):\n        videoid = \"z2xEwSi2vaI\";\n        break\n    default:\n        videoid = \"uwXEOccuRyU\";\n}\n\nmsg.payload = {\n\"app\": \"YouTube\",\n\"type\": \"MEDIA\",\n\"videoId\": videoid\n};\n\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1500,"y":240,"wires":[["db1127cc.ff45f8"]]},{"id":"edaa6b5e.0aa918","type":"function","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Youtube/Azan Subuh","func":"let playlist_random = getRndInteger(1,6);\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\nswitch (playlist_random) {\n    case(1):\n        videoid = \"qhp3gy2rDUU\";\n        break;\n    case(2):\n        videoid = \"kYgg0IW4Cpk\";\n        break;\n    case(3):\n        videoid = \"kutazqNu0OU\";\n        break;\n    case(4):\n        videoid = \"FTFyP-p3VTI\";\n        break;\n    case(5):\n        videoid = \"C5GaDD2gAqU\";\n        break\n    case(6):\n        videoid = \"pVi8UTeKAso\";\n        break\n    default:\n        videoid = \"FTFyP-p3VTI\";\n}\n\nmsg.payload = {\n\"app\": \"YouTube\",\n\"type\": \"MEDIA\",\n\"videoId\": videoid\n};\n\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1500,"y":180,"wires":[["db1127cc.ff45f8"]]},{"id":"e9044ba9.d82468","type":"wake on lan","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","mac":"20:17:42:d8:4e:8f","host":"192.168.0.255","udpport":9,"name":"LGTV","x":1250,"y":200,"wires":[]},{"id":"db1127cc.ff45f8","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"out-googletvchromecast","links":["56211c60.08f6c4","cf92c33d.6c7d5"],"x":1835,"y":260,"wires":[]},{"id":"799108f0.41bb28","type":"api-call-service","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Turn ON","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"turn_on","entityId":"media_player.chromecast","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1040,"y":380,"wires":[["124eef07.c54df1"]]},{"id":"a6f0b09e.7dfd2","type":"delay","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1040,"y":240,"wires":[["cdc3643e.25f498","c25108a8.993cc8"]]},{"id":"277ffb75.6e3b34","type":"function","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Compare Times","func":"\n// construct newmsg\nnewmsg = {};\n\n// retrieve waktu solat from flow\nlet zone                = flow.get(\"zone\");\nlet data_download_date  = flow.get(\"data_download_date\");\nlet waktu_imsak         = flow.get(\"waktu_imsak\");\nlet subuhtime           = flow.get(\"waktu_subuh\");\nlet syuruktime          = flow.get(\"waktu_syuruk\");\nlet zohortime           = flow.get(\"waktu_zohor\");\nlet asartime            = flow.get(\"waktu_asar\");\nlet maghribtime         = flow.get(\"waktu_maghrib\");\nlet isyaktime           = flow.get(\"waktu_isyak\");\n\n// define other timing variables \n// PREFERENCE: add 1 minute with delay timer later to get exact azan at the minute vs. delayed\nvar minutesToAdd=1;\n\nconst now = new Date();\nconst hours = now.getHours().toString().padStart(2,'0');\nconst minutes = now.getMinutes().toString().padStart(2,'0');\n\nconst day = now.getDate();\nconst month = now.getMonth();\nconst year = now.getFullYear();\n\nconst compared_minute = new Date(now.getTime() + minutesToAdd*60000);\nconst compared_hours = compared_minute.getHours().toString().padStart(2,'0');\nconst compared_minutes = compared_minute.getMinutes().toString().padStart(2,'0');\n\n// used time for comparing later\nconst time = `${compared_hours}:${compared_minutes}`;\n\nif (time > subuhtime && time < syuruktime)\n{\n     flow.set(\"waktusolatsekarang\", \"Subuh\");\n     flow.set(\"waktusolatberikut\", \"Syuruk\");  \n     flow.set(\"time_waktusolatberikut\", syuruktime);  \n}\nelse if (time > syuruktime && time < zohortime)\n{\n    flow.set(\"waktusolatsekarang\", \"Syuruk\");\n    flow.set(\"waktusolatberikut\", \"Zohor\"); \n    flow.set(\"time_waktusolatberikut\", zohortime);  \n}\nelse if (time > zohortime && time < asartime)\n{\n    flow.set(\"waktusolatsekarang\", \"Zohor\");\n    flow.set(\"waktusolatberikut\", \"Asar\"); \n    flow.set(\"time_waktusolatberikut\", asartime);  \n}    \nelse if (time > asartime && time < maghribtime)\n{\n    flow.set(\"waktusolatsekarang\", \"Asar\");\n    flow.set(\"waktusolatberikut\", \"Maghrib\"); \n    flow.set(\"time_waktusolatberikut\", maghribtime);  \n}        \nelse if (time > maghribtime && time < isyaktime)\n{\n    flow.set(\"waktusolatsekarang\", \"Maghrib\");\n    flow.set(\"waktusolatberikut\", \"Isyak\"); \n    flow.set(\"time_waktusolatberikut\", isyaktime);  \n}     \nelse if (time > isyaktime || time < subuhtime)\n{\n    flow.set(\"waktusolatsekarang\", \"Isyak\");\n    flow.set(\"waktusolatberikut\", \"Subuh\"); \n    flow.set(\"time_waktusolatberikut\", subuhtime);  \n} \n// else \n// {\n//     flow.set(\"waktusolatsekarang\", \"unknown\");\n//     flow.set(\"waktusolatberikut\", \"unknown\"); \n//     flow.set(\"time_waktusolatberikut\", time); \n    \n// }\n  \n\nlet waktu_solat_sekarang = flow.get(\"waktusolatsekarang\");\nlet waktu_solat_berikut = flow.get(\"waktusolatberikut\");\nlet time_waktusolat_berikut = flow.get(\"time_waktusolatberikut\");\n\n// compare time to trigger for waktu solat\nif (time === subuhtime) \n{\n    newmsg.payload = \"Subuh\";\n    flow.set(\"waktusolatsekarang\", \"Subuh\");\n    flow.set(\"waktusolatberikut\", \"Syuruk\");   \n    flow.set(\"time_waktusolatberikut\", syuruktime);\n\n} else if (time  === syuruktime) \n{\n    newmsg.payload = \"Syuruk\";\n    flow.set(\"waktusolatsekarang\", \"Syuruk\");\n    flow.set(\"waktusolatberikut\", \"Zohor\");   \n    flow.set(\"time_waktusolatberikut\", zohortime);\n} else if (time  === zohortime) \n{\n    newmsg.payload = \"Zohor\";\n    flow.set(\"waktusolatsekarang\", \"Zohor\");\n    flow.set(\"waktusolatberikut\", \"Asar\");   \n    flow.set(\"time_waktusolatberikut\", asartime);    \n} else if (time  === asartime) \n{\n    newmsg.payload = \"Asar\";\n    flow.set(\"waktusolatsekarang\", \"Asar\");\n    flow.set(\"waktusolatberikut\", \"Maghrib\");   \n    flow.set(\"time_waktusolatberikut\", maghribtime);\n} else if (time  === maghribtime) \n{\n    newmsg.payload = \"Maghrib\";\n    flow.set(\"waktusolatsekarang\", \"Maghrib\");\n    flow.set(\"waktusolatberikut\", \"Isyak\");   \n    flow.set(\"time_waktusolatberikut\", isyaktime);\n} else if (time  === isyaktime) \n{\n    newmsg.payload = \"Isyak\";\n    flow.set(\"waktusolatsekarang\", \"Isyaka\");\n    flow.set(\"waktusolatberikut\", \"Subuha\");   \n    flow.set(\"time_waktusolatberikut\", isyaktime);\n} \nelse \n{  \n    //set payload empty so following flow does not trigger\n    newmsg.payload = \"\";\n}\n\n// Calculate remaining time (FUTURE - convert to function?)\n// ________________________________________________________\n// retrieve waktu solat set in flow context (from previous runs or updated above)\n\n//time_waktusolatberikut = time_waktusolatberikut;\n\n// retrieve next solat time hour and minutes\nconst ns_time_hour  = time_waktusolat_berikut.substring(0,2);\nconst ns_time_minutes = time_waktusolat_berikut.substring(3,5);\n\n// construct new date using current time and next solat time\nconst current_time  = new Date(year,month,day,hours,minutes);\nconst nextsolat_time  = new Date(year,month,day,ns_time_hour,ns_time_minutes);\n\n// establish next day midnight/day/month/year for Subuh calculation\nvar midnight_time   = now;\nmidnight_time.setHours(24,0,0,0);\nconst ns_next_day   = midnight_time.getDate();\nconst ns_next_month = midnight_time.getMonth();\nconst ns_next_year  = midnight_time.getFullYear();\n\n// Check if current time is before midnight and Subuh is next\n\n// at midnight current hour = 0\n// hence at midnight this should not run, and isya no earlier than 1800\nif ( waktu_solat_berikut == \"Subuh\" && hours > 18  )\n{\n    // then we calculate using time difference for next day time\n    var subuh_time      = new Date(ns_next_year,ns_next_month,ns_next_day,ns_time_hour,ns_time_minutes);\n    newmsg.time_waktuberikut = msConversion(subuh_time-current_time);\n}\nelse {\n    // else (for subuh) we expect current day is equal, after midnight so day is the same.\n    // for other prayers - it would be the same.\n    newmsg.time_waktuberikut = msConversion(nextsolat_time-current_time);\n}\n\n// used for later flows as payload will be replaced.\nnewmsg.waktu_solat = newmsg.payload;\nnewmsg.waktu_solat_sekarang = waktu_solat_sekarang;\nnewmsg.waktu_solat_berikut = waktu_solat_berikut;\n\n//for debugging\nnewmsg.time = time;\nnewmsg.currentnow = now;\nnewmsg.current_hour = hours;\nnewmsg.current_time = current_time;\nnewmsg.current_time_locale = current_time.toLocaleString();\nnewmsg.nextsolat_time = nextsolat_time.toLocaleString();\nnewmsg.midnight_time = midnight_time.toLocaleString();\n\n\nreturn newmsg;\n\nfunction msConversion(millis) {\n  let sec = Math.floor(millis / 1000);\n  let hrs = Math.floor(sec / 3600);\n  sec -= hrs * 3600;\n  let min = Math.floor(sec / 60);\n  sec -= min * 60;\n\n  sec = '' + sec;\n  sec = ('00' + sec).substring(sec.length);\n\n  if (hrs > 0) {\n    min = '' + min;\n    min = ('00' + min).substring(min.length);\n    return hrs + \" jam \" + min + \" minit\";\n  }\n  else {\n    return min + \" minit\";\n  }\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":200,"wires":[["746147b6.de9f68","8b88caa3.9776d8","1c81239f.dfd61c"]]},{"id":"4945c457.ae3a2c","type":"inject","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":"","topic":"","payload":"1","payloadType":"num","x":510,"y":120,"wires":[["e7de13f9.4c83f"]]},{"id":"4541b1d8.57bc5","type":"comment","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Minute by minute lookup","info":"### ## ### \n### ## ### additional nodes\n### ## ### \n### ## ### node-red-contrib-random-item \n# Via Cronjob","x":310,"y":120,"wires":[]},{"id":"73dbc05.7ae684","type":"link in","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"i-minute-pulse","links":["e7de13f9.4c83f"],"x":225,"y":200,"wires":[["277ffb75.6e3b34"]]},{"id":"e7de13f9.4c83f","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"o-minute-pulse","links":["73dbc05.7ae684","d659ebad.1d80a8"],"x":615,"y":120,"wires":[]},{"id":"b82459be.056f48","type":"delay","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1040,"y":320,"wires":[["208d52d.827ddae"]]},{"id":"511b9079.f8fcb","type":"function","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Audio/Azan Subuh","func":"\nmsg.payload = \"azansubuh.mp3\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1490,"y":120,"wires":[["8f54ce9.8394b3"]]},{"id":"ea4e5db9.99087","type":"function","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"Audio/Azan Random","func":"let playlist_random = getRndInteger(1,4);\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\nswitch (playlist_random) {\n    case(1):\n        mp3_id = \"azan_malaysia_tv3.mp3\";\n        break;\n    case(2):\n        mp3_id = \"azan_malaysia_shahalam.mp3\";\n        break;\n    case(3):\n        mp3_id = \"azan_misyari_rasyid_1.mp3\";\n        break;\n    case(4):\n        mp3_id = \"azan_misyari_rasyid_2.mp3\";\n        break;\n    default:\n        mp3_id = \"azan_malaysia_tv3.mp3\";\n}\n\nmsg.payload = mp3_id;\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1500,"y":300,"wires":[["8f54ce9.8394b3"]]},{"id":"8f54ce9.8394b3","type":"link out","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"WS Speaker Out - Audio/MP3","links":["b08e9a29.a14828"],"x":1835,"y":200,"wires":[],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"c25108a8.993cc8","type":"switch","z":"979d82cfea624e5f","g":"7a8ff58b.91c62c","name":"","property":"waktu_solat","propertyType":"msg","rules":[{"t":"eq","v":"Subuh","vt":"str"},{"t":"neq","v":"Subuh","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1250,"y":280,"wires":[["edaa6b5e.0aa918","511b9079.f8fcb"],["29ac26b3.c2dc6a","ea4e5db9.99087"]]}]

Bahagian 4 - Tambahan - Notifikasi 15 minit sebelum masuk waktu.

  1. Bahagian ini mirip fungsi perbandingan waktu untuk menentukan Waktu Solat.
  2. Sebaliknya - jam diawalkan sebanyak 15 minit agar perbandingan waktu dibuat 15 minit sebelum masuknya Waktu Solat tersebut.
  3. Ini membolehkan notifikasi/automation yang berasignan dibuat berbanding jika sudah masuk waktu - misalnya tutup langsir sebelum Maghrib atau memainkan Youtube Live video Makkah/Madinah di TV sementara menunggu masuk waktu solat.

Step4

[{"id":"98788efd.44a6e","type":"group","z":"979d82cfea624e5f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["74e66f38.426cb","fcf14654.85b548","c0e5a10a.1b4a1","b34fbd1d.58cc8","1e72e30b.c9fddd","b5db9719.a92f08","4002d28e.02073c","259600f8.a7623","f80100ac.269b","9ad00e7.b9d25f","5c500f37.d472a","a1ed1f34.48f3a","119b99fd.b03276","ec033520.b1ec68","6e8fb92d.21aca8","20abe24.1e9aa1e","453f964b.e5b708","c52dbcac.54844","81104bf2.740698","d1e1ccf6.3d214","a1e4f146.707a1","7bde58f9.fc4918","d659ebad.1d80a8"],"x":174,"y":579,"w":1772,"h":402},{"id":"74e66f38.426cb","type":"function","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Compare Times 15 minutes earlier","func":"\n// construct newmsg\nnewmsg = {};\n\n// retrieve waktu solat from flow\nlet zone                = flow.get(\"zone\");\nlet data_download_date  = flow.get(\"data_download_date\");\nlet waktu_imsak         = flow.get(\"waktu_imsak\");\nlet subuhtime           = flow.get(\"waktu_subuh\");\nlet syuruktime          = flow.get(\"waktu_syuruk\");\nlet zohortime           = flow.get(\"waktu_zohor\");\nlet asartime            = flow.get(\"waktu_asar\");\nlet maghribtime         = flow.get(\"waktu_maghrib\");\nlet isyaktime           = flow.get(\"waktu_isyak\");\n\n//add 15 minutes to current time to compare with actual to 15 minute pre info\nvar minutesToAdd        = 15;\nvar currentDate         = new Date();\nvar previousDate        = new Date(currentDate.getTime() + minutesToAdd*60000);\n\nconst prehours          = previousDate.getHours().toString().padStart(2,'0');\nconst preminutes        = previousDate.getMinutes().toString().padStart(2,'0');\nconst pretime           = `${prehours}:${preminutes}`;\n\nnewmsg.kawasan = zone;\n\n\nif (pretime === subuhtime) \n{\n    newmsg.payload = \"Subuh\";\n    newmsg.solat_time = subuhtime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === syuruktime) \n{\n    newmsg.payload = \"Syuruk\";\n    newmsg.solat_time = syuruktime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === zohortime) \n{\n    newmsg.payload = \"Zohor\";\n    newmsg.solat_time = zohortime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === asartime) \n{\n    newmsg.payload = \"Asar\";\n    newmsg.solat_time = asartime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === maghribtime) \n{\n    newmsg.payload = \"Maghrib\";\n    newmsg.solat_time = maghribtime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === isyaktime) \n{\n    newmsg.payload = \"Isyak\";\n    newmsg.solat_time = isyaktime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} \n\nreturn newmsg;\n\n\n// debugging\n//return newmsg;\n//newmsg.waktu = newmsg.payload;\n//newmsg.topic = pretime;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":620,"wires":[["c0e5a10a.1b4a1","7bde58f9.fc4918"]]},{"id":"fcf14654.85b548","type":"change","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Craft Message","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"🕌 Assalamualaikum dan perhatian. Dalam masa 15 minit lagi akan masuk waktu \" & $.payload &\" pada jam \" & $.solat_time &\" bagi zon \" & $.kawasan","tot":"jsonata"},{"t":"set","p":"data","pt":"msg","to":"$.payload ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":700,"wires":[["4002d28e.02073c","259600f8.a7623","6e8fb92d.21aca8","20abe24.1e9aa1e","c52dbcac.54844"]]},{"id":"c0e5a10a.1b4a1","type":"switch","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Pre Solat Spesific Commands","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Subuh","vt":"str"},{"t":"eq","v":"Syuruk","vt":"str"},{"t":"eq","v":"Zohor","vt":"str"},{"t":"eq","v":"Asar","vt":"str"},{"t":"eq","v":"Maghrib","vt":"str"},{"t":"eq","v":"Isyak","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":410,"y":800,"wires":[["fcf14654.85b548","f80100ac.269b"],[],["fcf14654.85b548","119b99fd.b03276"],["fcf14654.85b548","119b99fd.b03276"],["b34fbd1d.58cc8","fcf14654.85b548"],["fcf14654.85b548"]]},{"id":"b34fbd1d.58cc8","type":"link out","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Pre-Maghrib","links":["901dc84f.a4cdf8"],"x":810,"y":820,"wires":[],"l":true},{"id":"1e72e30b.c9fddd","type":"delay","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1300,"y":880,"wires":[["b5db9719.a92f08"]]},{"id":"b5db9719.a92f08","type":"api-call-service","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Google say","server":"","version":3,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.chromecast","data":"{\"message\":\"{{payload}}\",\"cache\":\"true\",\"language\":\"id\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"payload","valueType":"msg"}],"queue":"none","x":1470,"y":880,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini1.svg"},{"id":"4002d28e.02073c","type":"link out","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"T-PreWaktuSolat","links":["8718a1dd.5beb7"],"x":1115,"y":820,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"259600f8.a7623","type":"link out","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"WS Speaker Out - TTS","links":["c4134f1d.de9a5"],"x":1115,"y":660,"wires":[],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"f80100ac.269b","type":"link out","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Waktu Solat Broadcast","links":["42d27463.d3c9ac","71fe748c.fce81c"],"x":840,"y":760,"wires":[],"l":true},{"id":"9ad00e7.b9d25f","type":"delay","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1320,"y":700,"wires":[["ec033520.b1ec68"]]},{"id":"5c500f37.d472a","type":"change","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Override TV Scheduler - Turn ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":940,"wires":[["a1ed1f34.48f3a"]]},{"id":"a1ed1f34.48f3a","type":"link out","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"out-tv-scheduler-on","links":["eeaddb3.ba5fc28"],"x":1075,"y":940,"wires":[]},{"id":"119b99fd.b03276","type":"api-current-state","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Scheduler Active","server":"","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.mos_tv_scheduler","state_type":"str","blockInputOverrides":false,"outputProperties":[],"x":630,"y":940,"wires":[["5c500f37.d472a"],[]]},{"id":"ec033520.b1ec68","type":"function","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Randomizer + Youtube","func":"let playlist_random = getRndInteger(1,5);\nvar now = new Date();\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\n//get global variable\nvar g = global.get(\"homeassistant\");\n//get states variable\nvar states = g.homeAssistant.states;\n//get the actual entity that we want\nvar video1 = states[\"input_text.azan_streaming_link_1\"].state;\nvar video2 = states[\"input_text.azan_streaming_link_2\"].state;\nvar video3 = states[\"input_text.azan_streaming_link_3\"].state;\nvar video4 = states[\"input_text.azan_streaming_link_4\"].state;\nvar video5 = states[\"input_text.azan_streaming_link_5\"].state;\n\nswitch (playlist_random) {\n    case(1):\n        // live makkah\n        // videoid = \"YsPvZXBFJko\";\n        videoid = video1;\n        break;\n    case(2):\n        // live madinah\n        //videoid = \"ERl92J7JREg\";\n        videoid = video2;\n        break;\n    case(3):\n        // madinah playback\n        //videoid = \"kGCCzo5jYhQ\";\n        videoid = video3;\n        break;\n    case(4):\n        // surah kahfi\n        //videoid = \"-rzG4nLUq-8\";\n        videoid = video4;\n        break;\n    case(5):\n        // live makkah\n        //videoid = \"2KRh6jCWEzI\";\n        videoid = video5;\n        break\n    default:\n        videoid = \"-rzG4nLUq-8\";\n}\n\nmsg.videoid = videoid;\nmsg.playlist = playlist_random;\nmsg.triggertime = now;\n\nmsg.payload = {\n\"app\": \"YouTube\",\n\"type\": \"MEDIA\",\n\"videoId\": videoid\n};\n\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1560,"y":700,"wires":[["d1e1ccf6.3d214","a1e4f146.707a1","453f964b.e5b708"]]},{"id":"6e8fb92d.21aca8","type":"api-call-service","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"Turn ON","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"turn_on","entityId":"media_player.chromecast","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1140,"y":880,"wires":[["1e72e30b.c9fddd"]]},{"id":"20abe24.1e9aa1e","type":"wake on lan","z":"979d82cfea624e5f","g":"98788efd.44a6e","mac":"20:17:42:d8:4e:8f","host":"192.168.0.255","udpport":9,"name":"LGTV","x":1150,"y":620,"wires":[]},{"id":"453f964b.e5b708","type":"link out","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"out-googletvchromecast","links":["56211c60.08f6c4","cf92c33d.6c7d5"],"x":1875,"y":700,"wires":[]},{"id":"c52dbcac.54844","type":"switch","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"","property":"waktu","propertyType":"msg","rules":[{"t":"neq","v":"Isyak","vt":"str"},{"t":"eq","v":"Isyak","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1150,"y":720,"wires":[["9ad00e7.b9d25f"],["81104bf2.740698"]]},{"id":"81104bf2.740698","type":"link out","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"o-presolat_broadcast","links":["82755dc7.5621f"],"x":1295,"y":760,"wires":[]},{"id":"d1e1ccf6.3d214","type":"debug","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1850,"y":760,"wires":[]},{"id":"a1e4f146.707a1","type":"ha-entity","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"PreSolat Youtube Log","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"PreSolat Youtube Log"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:youtube"},{"property":"unit_of_measurement","value":""}],"state":"playlist","stateType":"msg","attributes":[{"property":"Youtube Video","value":"videoid","valueType":"msg"},{"property":"Triggered time","value":"triggertime","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1800,"y":640,"wires":[[]]},{"id":"7bde58f9.fc4918","type":"debug","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"PreSolat","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":620,"wires":[]},{"id":"d659ebad.1d80a8","type":"link in","z":"979d82cfea624e5f","g":"98788efd.44a6e","name":"i-minute-pulse","links":["e7de13f9.4c83f"],"x":215,"y":620,"wires":[["74e66f38.426cb"]]}]

Bahagian 5 - Pengumuan Waktu, Memainkan Azan di Speaker dan Youtube Azan/Live Makkah/Madinah di TV.

  1. Pengumuman Waktu
    1. Servis Home Assistant google_translate_say digunakan. Pastikan servis ini sudah ditetapkan di dalam configuration.yaml bagi Integration Google TTS.
    2. Disebabkan kekangan platform Google TTS (yang disediakan oleh Home Assistant) - bahasa terdekat yang dapat diambil berbanding Bahasa Malaysia adalah Bahasa Indonesia dengan penetapan language:id.
    3. Node craft Message menetapkan apa yang mahu dikatakan secara dinamik - yakni melalui payload yang diterima dari node-node sebelum ini, termasuk pengumuman zone waktu solat.
  2. Bagi memainkan audio Azan di speaker:
    1. Servis dari Home Assistant play_media digunakan. Servis ini mencari fail yang ditetapkan di path media-source://media_source/local/ atau jika dari perspektif direktori HA : folder media (sama level dengan direktori config).
    2. Speaker boleh ditetapkan secara sendirian atau group.
    3. Beberapa pilihan mp3 azan disimpan di media folder - agar pemilihan azan boleh dibuat secara rawak.
  3. Bagi memainkan video Youtube Azan/Live Makkah/Madinah di TV:
    1. Berbanding diatas dan setelah beberapa perbandingan dibuat - node cast2tv digunakan yang membolehkan Node-Red berhubung terus dengan Chromecast devices.
    2. Perbezaan (dan pengamatan) - node cast2tv ini adalah ia lebih mudah dan baik berbanding media_player disebabkan ia tidak bergantung kepada Home Assistant untuk memulakan Cast. Mutu dan kualiti video yang dimainkan juga lebih baik menggunakan library npm cast2tv berbanding Home Assistant yang menggunakan library pyChromecast bagi tujuan sama.
    3. Google Chromecast devices pada asasnya juga ada memberi signal CEC HDMI yang membolehkan TV dihidupkan secara automatik apabila cast dimulakan tetapi signal ini tidaklah dapat dipercayai berfungsi selalui, lebih-lebih lagi bagi yang begantung notifikasi Azan Subuh. Jadi tambahan node Wake-on-LAN WOL digunakan untuk menghidupkan TV dahulu (tidak semua TV support ini termasuk Wifi - LAN adalah cara terbaik).
    4. Sama seperti audio - beberapa playlist boleh ditetapkan supaya pemilihan secara rawak dapat dibuat. Bagi Live Makkah / Madinah - livestream ini acapkali ditukar (diturunkan sebab copyright notice) jadi tambahan penepatan dibuat supaya playlist ini boleh diubah di Home Assistant melalui input_text tanpa perlu mengubahnya di Node-Red semula.

Step 5

[{"id":"cf92c33d.6c7d5","type":"link in","z":"979d82cfea624e5f","name":"in-googletvchromecast","links":["db1127cc.ff45f8","453f964b.e5b708"],"x":835,"y":1220,"wires":[["5c8b6549.8a20dc"]]},{"id":"c05e8a0a.be02d8","type":"api-call-service","z":"979d82cfea624e5f","name":"TTS","server":"","version":3,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.living_room_speaker","data":"{\"message\":\"{{payload}}\",\"cache\":\"true\",\"language\":\"id\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":1320,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"8a9cb680.d7e8f8","type":"api-call-service","z":"979d82cfea624e5f","name":"Set Volume 0.7","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.7\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":1280,"wires":[["c05e8a0a.be02d8"]]},{"id":"c4134f1d.de9a5","type":"link in","z":"979d82cfea624e5f","name":"WS Speaker In - TTS","links":["208d52d.827ddae","259600f8.a7623"],"x":400,"y":1320,"wires":[["aa2959c9.a2e4e8"]],"icon":"node-red-contrib-cast/google-home-mini2.svg","l":true},{"id":"aa2959c9.a2e4e8","type":"api-current-state","z":"979d82cfea624e5f","name":"WS Not occupied","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"switch.flag_nomotion_walidstudy","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":630,"y":1320,"wires":[["8a9cb680.d7e8f8"],["968d63f1.d7f6c"]]},{"id":"968d63f1.d7f6c","type":"api-call-service","z":"979d82cfea624e5f","name":"Set Volume 0.2","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.2\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":1360,"wires":[["c05e8a0a.be02d8"]]},{"id":"42554b7d.917a04","type":"api-call-service","z":"979d82cfea624e5f","name":"Audio/Azan Subuh","server":"","version":3,"debugenabled":true,"service_domain":"media_player","service":"play_media","entityId":"media_player.living_room_speaker","data":"{\"media_content_id\":\"media-source://media_source/local/{{payload}}\",\"media_content_type\":\"audio/mp3\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1250,"y":1460,"wires":[[]]},{"id":"b08e9a29.a14828","type":"link in","z":"979d82cfea624e5f","name":"WS Speaker In - Audio/MP3","links":["8f54ce9.8394b3","8cf62c63.4fabb","b22d32be.52878"],"x":380,"y":1460,"wires":[["58eb9f86.83d79"]],"icon":"node-red-contrib-cast/google-home-mini2.svg","l":true},{"id":"a10738af.905948","type":"api-call-service","z":"979d82cfea624e5f","name":"Set Volume 0.8","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.8\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":1420,"wires":[["42554b7d.917a04"]]},{"id":"58eb9f86.83d79","type":"api-current-state","z":"979d82cfea624e5f","name":"WS Not occupied","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"switch.flag_nomotion_walidstudy","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":630,"y":1460,"wires":[["a10738af.905948"],["5c14cb4c.940c34"]]},{"id":"5c14cb4c.940c34","type":"api-call-service","z":"979d82cfea624e5f","name":"Set Volume 0.15","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.15\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":1500,"wires":[["42554b7d.917a04"]]},{"id":"5c8b6549.8a20dc","type":"castv2-sender","z":"979d82cfea624e5f","name":"Google TV","connection":"1f6c530c.e04cdd","x":950,"y":1220,"wires":[[]]},{"id":"1f6c530c.e04cdd","type":"castv2-connection","name":"","target":"GoogleTV","host":"","port":"8009"}]

Bahagian 6 - Lain-lain

  1. Telegram node /getwaktusolat membolehkan command untuk mendapatkan waktu solat terkini dari Telegram. Begitu juga /refreshwaktusolat jika ingin memperbaharui data dari Telegram.

  2. Switch Node yang digunakan untuk memainkan azan dan notifkasi juga boleh digunakan sebagai trigger bagi memulakan automation lain-lain. Contoh disertakan seperti:

    1. Trigger scenes yang sudah ditetapkan di dalam Home Assistant - seperti membuka lampu luar dan menutup langsir 15 minit sebelum Maghrib.

      Maghrib Scene

    2. Mendapatkan hadith daripada Sunnah.com dan menghantar ke Telegram supaya boleh dibaca dan perkongsian bersama keluarga selesai Solat jemaah Maghrib.

      GetHadith

    3. 30 minit selepas masuk waktu Subuh - menghantar Weather forecast ke Telegram supaya boleh tentukan cuaca baik atau tidak untuk berjogging.

      WeatherForecast

  1. Home Assistant with Node-Red. Boleh rujuk tutorial ini; bagi beginner - pastikan Node Red boleh dicapai melalui Home Assistant (melalui link di menu tepi).

    1. Tutorial Pertama dari juanmtech.
    2. Tutorial Kedua dari ShahrulNizam.com
  2. Bagi Home Assistant, berikut diperlukan:

    1. Node-Red companion integration; install melalui HACS. Ini membolehkan entity seperti sensor dibuat oleh Node Red berbanding konfigurasi Home Assistant menggunkan configuration.yaml atau helpers.

    Tip: Nama entity node hendaklah di-isi dahulu sebelum deploy. Ini membolehkan nama entity yang diberi mengikut kehendak kita. Jika tidka di-isi Node-Red/HA akan memberi nama secara rawak dan ini tidak boleh ditukar melainkan node dibuang dan dibuat semula.

    1. Bagi pemilihan video streaming dari Makkah / Madinah - flow ini menggunakan helper input_text yang perlu ditetapkan di Home Assistant. Melalui Configuration -> Helpers -> 'Add Helper', tetapkan 5 input_text dengan entity ID input_text.azan_streaming_link_1, input_text.azan_streaming_link_2, input_text.azan_streaming_link_3, input_text.azan_streaming_link_4, input_text.azan_streaming_link_5.

      Setiap input_text ini kemudian di-isi dengan video id youtube seperti berikut:

    2. Vertical stack in card](https://github.com/ofekashery/vertical-stack-in-card) membolehkan penyusunan lovelace secara kompak tanpa border.

    3. Bagi laungan azan, copy dari folder MP3 azan dan simpan di folder homeassistant /media

    Mp3 azan

  3. Bagi Node-Red; pallette berikut diperlukan (Ikon burger di atas hujung kanan -> Manage Pallette -> Install )

    1. Keperluan:
      1. node-red-contrib-home-assistant-websocket - Pre-installed jika Node-Red dipasang melalui Home Assistant Supervisor.
      2. node-red-contrib-cron-plus - Bagi menjalankan tugasan berkala mengikut setting yang ditetapkan. Di dalam dunia linux - ini adalah seperti cronjobs.
    2. Tambahan (Node ini boleh dibuang jika tidak memerlukan feature-feature ini).
      1. node-red-contrib-telegrambot - Bagi memberi notifkasi melalui Telegram.
      2. node-red-dashboard - Bagi feature dashboard Node-Red.
      3. node-red-node-wol - Bagi feature Wake on LAN supaya TV dapat dihidupkan dari automation.
      4. node-red-contrib-castv2 - Bagi membolehkan Node-Red berhubung terus dengan Chromecast devices dan memulakan servis, misalnya casting Youtube video.
  4. Bagi Telegram - mempunyai Telegram bot and chat ids. Tutorial dari TheSmartHomeBook ini mudah difahami dan diikuti.

Tip: Bagi yang sudah mempunyai Telegram integration di Home Assistant; asignkan bot dengan menghidupkan satu lagi bot dan channel khas bagi Node Red.

  1. Tentukan Zone bagi kawasan anda melalui listing ini. Contohnya; Bagi kawasan Miri; kodnya adalah SWK02.

  2. Import Waktu Solat Flow ke dalam Node Red (Ikon burger di atas hujung kanan -> Import). Satu tab baru akan dibuka dengan nama 'Waktu Solat'

  3. Selesai Import dan sebelum click Deploy, beberapa ketatapan perlu dibuat dahulu:

    1. Ubah zone di dalam node Solat API dan Zone. Gantikan const zone_api = 'SWK02';` dengan zone kawasan anda.

      Set Zone

    2. Node-node yang menunjukan segi-tiga merah hendaklah diubah configuration dahulu.

      Node Setup

      1. Node Home Assistant (Warna biru) - Tetapkan supaya ia dapat akses ke Home Assistant. Bagi yang install melalui Supervisor - pilih server Home Assistant yang sudah disediakan.

        HomeAssistantNode

      2. Telegram (Logo Telegram) - tetapkan Bot-Name dan Token dan Users (nickname) yang di dalam configuration. Biarkan chatID kosong.

        Telegram

        Bagi Chat ID - isikan di function block berikut

        Telegram ID

        Ini supaya content yang diterima Telegram boleh diubah mengikut markdown yang ditetakan - misalnya sebagai Mesej, Gambar atau HTML.

        Untuk mendapatkan Bot dan ChatID noleh rujuk seperti tutorial. Boleh rujuk juga tips saya bagi memanfaatkan notifikasi Telegram dengan optimum.

      3. Video - Cast2TV (Logo Chromecast) - Tetapkan device chromecast dengan menekan butang search. Senarai device yang mempunyai feature chromecast akan disenaraikan - pilih dan tetapkan satu (yang boleh mengeluarkan video).

        Cast2TV

      4. Audio - Media Player - Tetapkan entity id bagi media_player tersedia yang digunakan di dalam Home Assistant.

        Media Player

      5. Wake On Lan (Logo Mentol) - tetapkan MAC ID dan IP Address bagi TV anda yang dihubungkan melalui LAN.

        Wake-On-LAN

    3. Setelah semua error dan settings ditetapkan - baru click 'Deploy'.

    4. Bagi kali pertama - Klik inject node Tekan sekali untuk kali pertama - ini membolehkan data didownload terlebih dahulu tanpa menunggu bulan hadapan.

  4. Home Assistant

Attributes

  • Melalui Node-Red companion integration yang sudah awal tadi diinstall -pergi ke Configuration -> Integrations -> Node-Red . Entity-entity berikut sekarang tersedia:

    -sensor.zone_waktu_solat

    -sensor.solat_bakiwaktu

    -sensor.waktu_solat - Dengan attribute setiap waktu solat.

    -sensor.subuh, sensor.syuruk, sensor.zohor, sensor.asar, sensor.maghrib, sensor.isyak

  1. Lovelace utama - Import and dan ubah ikut citarasa

![Lovelace](https://raw.githubusercontent.com/anas-ivs/HA-NR-WaktuSolatJakim/main/images/Lovelace-Waktu Solat.PNG)

type: custom:vertical-stack-in-card
cards:
  - type: entity
    entity: sensor.waktu_solat
    name: 'Waktu Solat '
  - type: markdown
    content: >
      Sekarang waktu
      **{{state_attr('sensor.solat_bakiwaktu','waktu_solat_sekarang')}}**. 
      Waktu {{state_attr('sensor.solat_bakiwaktu','waktu_solat_berikut')}} dalam
      masa {{states('sensor.solat_bakiwaktu')}}.
  - type: glance
    style: |
      ha-card {
        background-color: var(--primary-background-color);
        border-radius: 15px;
        margin: 10px;
        font-size: 6 px
        box-shadow:
          {% if is_state('sun.sun', 'above_horizon') %}
            -4px -4px 8px rgba(255, 255, 255, .5), 5px 5px 8px rgba(0, 0, 0, .03);
          {% elif is_state('sun.sun', 'below_horizon') %}
            -5px -5px 8px rgba(50, 50, 50, .2), 5px 5px 8px rgba(0, 0, 0, .08);
          {% endif %}
       }
        .card-header {
        font-size: 6 px
      }
    entities:
      - entity: sensor.subuh
      - entity: sensor.syuruk
      - entity: sensor.zohor
      - entity: sensor.asar
      - entity: sensor.maghrib
      - entity: sensor.isyak
    state_color: true
    columns: 6

  1. Lovelace penyelengaraan (simpan di dashboard khas supaya tidak mudah diubah)

    Maintenance Dashboard

type: custom:vertical-stack-in-card
cards:
  - type: entities
    entities:
      - entity: sensor.waktu_solat
        secondary_info: last-updated
      - entity: sensor.solat_bakiwaktu
    title: Waktu Solat API
  - type: entities
    entities:
      - entity: sensor.presolat_youtube_log
        secondary_info: last-updated
      - entity: input_text.azan_streaming_link_1
      - entity: input_text.azan_streaming_link_2
      - entity: input_text.azan_streaming_link_3
      - entity: input_text.azan_streaming_link_4
      - entity: input_text.azan_streaming_link_5
    title: Streaming Broadcast
  - type: grid
    cards:
      - type: button
        tap_action:
          action: toggle
        entity: switch.waktu_solat_api_update
        name: Update Waktu Solat
      - type: button
        tap_action:
          action: toggle
        entity: switch.trigger_cast_livemacamadinah
        name: Trigger Broadcast
    columns: 3
    square: true

Seperti spageti di atas, kod ini sangat panjang. Import dan paste di Node-Red, ikut langkah langkah pemasangan.

[{"id":"b192c009.52f1f","type":"tab","label":"WaktuSolat","disabled":false,"info":""},{"id":"22cc95d.eb1396a","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["d90544ba.c77558","498816d3.2fa8a8","ffdef2de.a7f2d","20d9593d.682a16","425ca14d.eb33c","51fac522.6e50fc","8a34191d.af0b48","95259768.a97368","79dfebef.0f8044"],"x":114,"y":2539,"w":1042,"h":202},{"id":"260d2b01.70e414","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["88751888.228788","44aaf8a8.5112c8","b8ba0e9.b0c5ef","8e6c012.23483","8c2c1881.178c48","1e728149.1a3d9f","39c4a930.3a44a6","4035e3f1.18291c","3b062c86.b3af34","b6d7ae1.b1a285","e3c5aad2.edb9c8","d2ea7e4.7022d8"],"x":114,"y":1959,"w":1002,"h":382},{"id":"4ab71376.db126c","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["901dc84f.a4cdf8","241bab76.ce56d4","e366b877.c66bf8"],"x":114,"y":2379,"w":512,"h":142},{"id":"621aaea6.50ac3","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["371ec913.5f6726","86133ba6.a8d9f8","4c277dfb.098854","a8edf8c6.0ac928","f8af1838.d32f78","8870a7b0.dc6df8","4a67e276.26637c","79962577.886d2c","8475476f.84bdc8","ec295e23.a85c7","a6f28b9d.b65af8","c8023b05.eb95b8","ffbb9922.968248","42ec6eeb.68c1e","6f51f1a4.9d5fb","78231aab.c50324","1b2f2219.a0563e","7a213032.e050d","8c7b13db.5de7c","5ca1cb56.9a8594"],"x":1294,"y":139,"w":532,"h":662},{"id":"7a8ff58b.91c62c","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["1c81239f.dfd61c","fda63eeb.b7931","e79ae7ad.22ab78","2dee4275.f2107e","cdc3643e.25f498","208d52d.827ddae","1b55833e.01921d","124eef07.c54df1","728a09a9.c18338","ac9c1347.cae03","746147b6.de9f68","8b88caa3.9776d8","29ac26b3.c2dc6a","edaa6b5e.0aa918","e9044ba9.d82468","db1127cc.ff45f8","799108f0.41bb28","a6f0b09e.7dfd2","277ffb75.6e3b34","4945c457.ae3a2c","4541b1d8.57bc5","73dbc05.7ae684","e7de13f9.4c83f","59da3820.b2d318","6bec99a3.efd218","71d7868c.8ce2f8","32e2cb3f.50bbe4","36520c57.78e224","54a77ca8.db6e64","e1805de9.11402","efeba8c4.0adf98","2c1e71d0.6c654e","ca103348.ad75d","b82459be.056f48","511b9079.f8fcb","ea4e5db9.99087","8f54ce9.8394b3","c25108a8.993cc8","cc26b38a.adcfd","95706046.870b7"],"x":94,"y":919,"w":2392,"h":522},{"id":"8f720014.0c8dd","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["bc226d11.f8c07","8f1beade.b14ee8","c3fd6fe.d515f9","e92332f7.68a4e","9b5c289.e0fbdd8","13a693b5.92c5ec","1b33b873.4f6548"],"x":1144,"y":1959,"w":722,"h":242},{"id":"9062f1c5.aa7c5","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["5aefb977.b44158","b318ba38.2327e8","19583de2.453ca2","8058345.829ddc8","e13bdfe0.eb97f","5bd3ab66.7f3314","46354ffa.7496e","b240395f.9b6608","ba1a529d.24a2","433e9897.86b008","9915eec0.c99aa","a7eb50fb.d8abe","f25c50d8.9c1e5","30701843.f92f38","61759b88.e98484","4779b8bd.a8c1d8","7091448e.5fb06c","570ce4f9.0d6a2c","d9629a0e.914068"],"x":1854,"y":139,"w":1112,"h":502},{"id":"98788efd.44a6e","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["74e66f38.426cb","fcf14654.85b548","c0e5a10a.1b4a1","b34fbd1d.58cc8","1e72e30b.c9fddd","b5db9719.a92f08","4002d28e.02073c","259600f8.a7623","f80100ac.269b","9ad00e7.b9d25f","ec033520.b1ec68","6e8fb92d.21aca8","20abe24.1e9aa1e","453f964b.e5b708","717e413a.a5349","c52dbcac.54844","81104bf2.740698","d1e1ccf6.3d214","a1e4f146.707a1","7bde58f9.fc4918","d659ebad.1d80a8"],"x":114,"y":1499,"w":1772,"h":342},{"id":"dbf68c7f.edcbc","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["b1ff6ece.3655e","de205768.74e188","82755dc7.5621f","9bdd154d.867238","959e20b4.6fef5","74a37dc0.0bcb14","7bf0c863.e16d58","3fac0cec.ad6c84","7b96fb1d.66d8e4","3da66b22.ed6754","4626302c.c7fad","19c4226e.16936e"],"x":1934,"y":1519,"w":952,"h":322},{"id":"e0364aba.76dc18","type":"group","z":"b192c009.52f1f","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["3c0048b4.36eee8","e84546cd.7ebf58","8f5b75a5.c43498","eacfd748.c0ef98","dff1ae19.4d009","592fb7be.42cd38","e73e172.4e0b9e8"],"x":1194,"y":2539,"w":702,"h":222},{"id":"1c81239f.dfd61c","type":"switch","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Solat Spesific Commands","property":"waktu_solat","propertyType":"msg","rules":[{"t":"eq","v":"Subuh","vt":"str"},{"t":"eq","v":"Syuruk","vt":"str"},{"t":"eq","v":"Zohor","vt":"str"},{"t":"eq","v":"Asar","vt":"str"},{"t":"eq","v":"Maghrib","vt":"str"},{"t":"eq","v":"Isyak","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":310,"y":1280,"wires":[["fda63eeb.b7931","2dee4275.f2107e"],["e79ae7ad.22ab78"],["fda63eeb.b7931"],["fda63eeb.b7931"],["fda63eeb.b7931","1b55833e.01921d"],["fda63eeb.b7931"]]},{"id":"fda63eeb.b7931","type":"change","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Craft Message","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"🕌 Kini telah masuk waktu solat \" & $.waktu_solat","tot":"jsonata"},{"t":"set","p":"data","pt":"msg","to":"$.payload ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":1140,"wires":[["e9044ba9.d82468","799108f0.41bb28","a6f0b09e.7dfd2","b82459be.056f48"]]},{"id":"3db3477e.6fd1a8","type":"link in","z":"b192c009.52f1f","name":"","links":[],"x":5,"y":1080,"wires":[[]]},{"id":"241bab76.ce56d4","type":"api-call-service","z":"b192c009.52f1f","g":"4ab71376.db126c","name":"Maghrib Lights ON Scene","server":"","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.turn_out_lights_15_minutes_before_maghrib","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":490,"y":2420,"wires":[[]]},{"id":"901dc84f.a4cdf8","type":"link in","z":"b192c009.52f1f","g":"4ab71376.db126c","name":"15 Minit Sebelum Maghrib","links":["b34fbd1d.58cc8"],"x":250,"y":2440,"wires":[["241bab76.ce56d4","e366b877.c66bf8"]],"l":true},{"id":"e366b877.c66bf8","type":"api-call-service","z":"b192c009.52f1f","g":"4ab71376.db126c","name":"CLOSE Living Langsir","server":"","version":3,"debugenabled":false,"service_domain":"cover","service":"close_cover","entityId":"cover.front_living","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":480,"y":2480,"wires":[[]]},{"id":"e79ae7ad.22ab78","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Syuruk","links":["44aaf8a8.5112c8"],"x":690,"y":1280,"wires":[],"l":true},{"id":"88751888.228788","type":"api-call-service","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"Day Lights OFF Scene","server":"","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.turn_off_outdoor_lights_at_syuruk","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":560,"y":2000,"wires":[[]]},{"id":"44aaf8a8.5112c8","type":"link in","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"Waktu Syuruk/Sunrise","links":["e79ae7ad.22ab78"],"x":240,"y":2000,"wires":[["88751888.228788","b8ba0e9.b0c5ef","8e6c012.23483","8c2c1881.178c48","e3c5aad2.edb9c8"]],"l":true},{"id":"b8ba0e9.b0c5ef","type":"api-call-service","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"OPEN Living Langsir","server":"","version":3,"debugenabled":false,"service_domain":"cover","service":"open_cover","entityId":"cover.front_living","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":560,"y":2060,"wires":[[]]},{"id":"8e6c012.23483","type":"api-call-service","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"Turn ON WS/US Monitors","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.us_monitor_switch, switch.plug_wsmonitor","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":570,"y":2120,"wires":[[]]},{"id":"2dee4275.f2107e","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Subuh","links":["3c0048b4.36eee8"],"x":690,"y":1240,"wires":[],"l":true},{"id":"3c0048b4.36eee8","type":"link in","z":"b192c009.52f1f","g":"e0364aba.76dc18","name":"Waktu Subuh","links":["2dee4275.f2107e"],"x":1290,"y":2580,"wires":[["e84546cd.7ebf58","dff1ae19.4d009"]],"l":true},{"id":"e84546cd.7ebf58","type":"api-call-service","z":"b192c009.52f1f","g":"e0364aba.76dc18","name":"Subuh Lights ON Scene","server":"","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.subuh_prayers","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1490,"y":2580,"wires":[[]]},{"id":"8c2c1881.178c48","type":"change","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"Craft Message Syuruk","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"Kini telah masuk waktu \" & $.payload ","tot":"jsonata"},{"t":"set","p":"data","pt":"msg","to":"$.payload ","tot":"jsonata"},{"t":"set","p":"waktu","pt":"msg","to":"$.waktu","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":2180,"wires":[["1e728149.1a3d9f"]]},{"id":"cdc3643e.25f498","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"T-Waktu Solat","links":["f25c50d8.9c1e5"],"x":1535,"y":980,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"208d52d.827ddae","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"WS Speaker Out - TTS","links":["c4134f1d.de9a5","e13bdfe0.eb97f"],"x":1175,"y":1300,"wires":[],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"1e728149.1a3d9f","type":"link out","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"T-SyurukandHadith","links":["f25c50d8.9c1e5"],"x":1075,"y":2180,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"39c4a930.3a44a6","type":"http request","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://type.fit/api/quotes","tls":"","persist":false,"proxy":"","authType":"","x":530,"y":2240,"wires":[["4035e3f1.18291c"]]},{"id":"4035e3f1.18291c","type":"function","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"","func":"msg.payload = msg.payload[getRndInteger(0,1642)];\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":2240,"wires":[["3b062c86.b3af34","b6d7ae1.b1a285"]]},{"id":"3b062c86.b3af34","type":"ui_text","z":"b192c009.52f1f","g":"260d2b01.70e414","group":"cbe50c39.f38f1","order":1,"width":6,"height":3,"name":"Daily Quote from https://type.fit/api/quotes","label":"Daily Quotes","format":"{{msg.payload.text}}","layout":"col-center","x":920,"y":2300,"wires":[]},{"id":"b6d7ae1.b1a285","type":"change","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"set","rules":[{"t":"delete","p":"_msgid","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"\"Quote of the day: \" & $.payload.text &\" ~ \" & $.payload.author","tot":"jsonata"},{"t":"delete","p":"payload.author","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"statusCode","pt":"msg"},{"t":"delete","p":"headers","pt":"msg"},{"t":"delete","p":"responseUrl","pt":"msg"},{"t":"delete","p":"redirectList","pt":"msg"},{"t":"delete","p":"responseCookies","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":2240,"wires":[["1e728149.1a3d9f"]]},{"id":"e3c5aad2.edb9c8","type":"delay","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":2180,"wires":[["39c4a930.3a44a6"]]},{"id":"d2ea7e4.7022d8","type":"telegram command","z":"b192c009.52f1f","g":"260d2b01.70e414","name":"/getquote","command":"/getquote","bot":"","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":340,"y":2240,"wires":[["39c4a930.3a44a6"],[]]},{"id":"d90544ba.c77558","type":"http request","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"Random Hadith","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":675,"y":2640,"wires":[["ffdef2de.a7f2d"]],"l":false},{"id":"498816d3.2fa8a8","type":"function","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"Get Random Hadith from Sunnah.com","func":"\n\nmsg.url = \"https://api.sunnah.com/v1/hadiths/random\";\nmsg.payload = \"\"\nmsg.headers = {};\n//default from https://sunnah.api-docs.io/1.0/hadiths/get-a-randomly-selected-hadith\nmsg.headers['x-api-key'] = 'SqD712P3E82xnwOAEOkGd5JZH8s9wRR24TqNFzjk';\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":2640,"wires":[["d90544ba.c77558"]]},{"id":"ffdef2de.a7f2d","type":"change","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"set","rules":[{"t":"set","p":"payload.hadtih_title","pt":"msg","to":"payload.hadith[0].chapterTitle","tot":"msg"},{"t":"set","p":"payload.hadtih_en","pt":"msg","to":"payload.hadith[0].body","tot":"msg"},{"t":"set","p":"payload.hadtih_ar","pt":"msg","to":"payload.hadith[1].body","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":735,"y":2640,"wires":[["79dfebef.0f8044"]],"l":false},{"id":"20d9593d.682a16","type":"template","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Collection: {{ payload.collection }}.\nBook Number: {{ payload.bookNumber }}.\nHadith Number: {{ payload.hadithNumber }}.\n\nTitle: {{ payload.hadtih_title }}.\n\n{{payload.hadtih_ar}}\n\n{{payload.hadtih_en}}\n\n\n","output":"str","x":1000,"y":2640,"wires":[["425ca14d.eb33c"]]},{"id":"425ca14d.eb33c","type":"link out","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"T-Hadith","links":["30701843.f92f38"],"x":1115,"y":2640,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"51fac522.6e50fc","type":"telegram command","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"/gethadith","command":"/gethadith","bot":"","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":220,"y":2700,"wires":[["498816d3.2fa8a8"],[]]},{"id":"1b55833e.01921d","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Maghrib","links":["8a34191d.af0b48","b674ddb2.4b5f7","dd2fe950.30acf8"],"x":700,"y":1320,"wires":[],"l":true},{"id":"8a34191d.af0b48","type":"link in","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"Waktu Maghrib","links":["1b55833e.01921d"],"x":220,"y":2640,"wires":[["498816d3.2fa8a8"]],"l":true},{"id":"95259768.a97368","type":"inject","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"Inject","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":2580,"wires":[["498816d3.2fa8a8"]]},{"id":"8f5b75a5.c43498","type":"function","z":"b192c009.52f1f","g":"e0364aba.76dc18","name":"","func":"const now = new Date();\nconst timeformsg = now.toString().slice(0, 24);\nmsg.message = \"Weather forecast for Miri. Date: \" +timeformsg;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1795,"y":2660,"wires":[["e73e172.4e0b9e8"]],"l":false},{"id":"eacfd748.c0ef98","type":"http request","z":"b192c009.52f1f","g":"e0364aba.76dc18","name":"Weather Forecast for Miri","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://my.meteoblue.com/visimage/meteogram_web_hd?look=KILOMETER_PER_HOUR%2CCELSIUS%2CMILLIMETER&apikey=5838a18e295d&temperature=C&windspeed=kmh&precipitationamount=mm&winddirection=3char&city=Miri&iso2=my&lat=4.399280&lon=113.991997&asl=8&tz=Asia%2FKuching&lang=en&sig=e9e61920acd296b814171de935c44385","tls":"","persist":false,"proxy":"","authType":"","x":1610,"y":2660,"wires":[["8f5b75a5.c43498"]]},{"id":"dff1ae19.4d009","type":"delay","z":"b192c009.52f1f","g":"e0364aba.76dc18","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1410,"y":2660,"wires":[["eacfd748.c0ef98"]]},{"id":"592fb7be.42cd38","type":"telegram command","z":"b192c009.52f1f","g":"e0364aba.76dc18","name":"/getweatherforecast","command":"/getweatherforecast","bot":"","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":1370,"y":2720,"wires":[["eacfd748.c0ef98"],[]]},{"id":"e73e172.4e0b9e8","type":"link out","z":"b192c009.52f1f","g":"e0364aba.76dc18","name":"T-Weatherforecast","links":["61759b88.e98484"],"x":1855,"y":2660,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"124eef07.c54df1","type":"delay","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"45","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1220,"y":1340,"wires":[["728a09a9.c18338"]]},{"id":"728a09a9.c18338","type":"api-call-service","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"TTS","server":"","version":3,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.chromecast","data":"{\"message\":\"{{payload}}\",\"cache\":\"true\",\"language\":\"id\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"payload","valueType":"msg"}],"queue":"none","x":1370,"y":1340,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini1.svg"},{"id":"ac9c1347.cae03","type":"delay","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1480,"y":1060,"wires":[["59da3820.b2d318","71d7868c.8ce2f8"]]},{"id":"746147b6.de9f68","type":"debug","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"SolatTimes","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":1040,"wires":[]},{"id":"8b88caa3.9776d8","type":"ha-entity","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Time to next prayer","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"solat_bakiwaktu"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"time_waktuberikut","stateType":"msg","attributes":[{"property":"Waktu Solat Sekarang","value":"waktu_solat_sekarang","valueType":"msg"},{"property":"Waktu Solat Berikut","value":"waktu_solat_berikut","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":610,"y":1100,"wires":[[]]},{"id":"29ac26b3.c2dc6a","type":"function","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Youtube/Azan Random","func":"let playlist_random = getRndInteger(1,6);\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\nswitch (playlist_random) {\n    case(1):\n        videoid = \"6IyJWdsbbYs\";\n        break;\n    case(2):\n        videoid = \"T7s3IFMktLo\";\n        break;\n    case(3):\n        videoid = \"vXQhE2CMhhM\";\n        break;\n    case(4):\n        videoid = \"my-IGBTNnYE\";\n        break;\n    case(5):\n        videoid = \"DdC7R3s7eCY\";\n        break\n    case(6):\n        videoid = \"z2xEwSi2vaI\";\n        break\n    default:\n        videoid = \"uwXEOccuRyU\";\n}\n\nmsg.payload = {\n\"app\": \"YouTube\",\n\"type\": \"MEDIA\",\n\"videoId\": videoid\n};\n\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1440,"y":1220,"wires":[["db1127cc.ff45f8"]]},{"id":"edaa6b5e.0aa918","type":"function","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Youtube/Azan Subuh","func":"let playlist_random = getRndInteger(1,6);\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\nswitch (playlist_random) {\n    case(1):\n        videoid = \"qhp3gy2rDUU\";\n        break;\n    case(2):\n        videoid = \"kYgg0IW4Cpk\";\n        break;\n    case(3):\n        videoid = \"kutazqNu0OU\";\n        break;\n    case(4):\n        videoid = \"FTFyP-p3VTI\";\n        break;\n    case(5):\n        videoid = \"C5GaDD2gAqU\";\n        break\n    case(6):\n        videoid = \"pVi8UTeKAso\";\n        break\n    default:\n        videoid = \"FTFyP-p3VTI\";\n}\n\nmsg.payload = {\n\"app\": \"YouTube\",\n\"type\": \"MEDIA\",\n\"videoId\": videoid\n};\n\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1440,"y":1160,"wires":[["db1127cc.ff45f8"]]},{"id":"bc226d11.f8c07","type":"wake on lan","z":"b192c009.52f1f","g":"8f720014.0c8dd","mac":"20:17:42:d8:4e:8f","host":"192.168.0.255","udpport":9,"name":"LGTV","x":1790,"y":2040,"wires":[]},{"id":"8f1beade.b14ee8","type":"delay","z":"b192c009.52f1f","g":"8f720014.0c8dd","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1500,"y":2160,"wires":[["9b5c289.e0fbdd8","1b33b873.4f6548"]]},{"id":"c3fd6fe.d515f9","type":"ha-entity","z":"b192c009.52f1f","g":"8f720014.0c8dd","name":"Node Red cast Makkah Madinah","server":"","version":1,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"trigger_cast_livemacamadinah"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":true,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1530,"y":2040,"wires":[["8f1beade.b14ee8","bc226d11.f8c07"],[]]},{"id":"e92332f7.68a4e","type":"inject","z":"b192c009.52f1f","g":"8f720014.0c8dd","name":"","props":[{"p":"enable","v":"false","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":1290,"y":2040,"wires":[["c3fd6fe.d515f9"]]},{"id":"e9044ba9.d82468","type":"wake on lan","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","mac":"20:17:42:d8:4e:8f","host":"192.168.0.255","udpport":9,"name":"LGTV","x":1070,"y":980,"wires":[]},{"id":"db1127cc.ff45f8","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"out-googletvchromecast","links":["56211c60.08f6c4","cf92c33d.6c7d5","b318ba38.2327e8"],"x":1675,"y":1240,"wires":[]},{"id":"9b5c289.e0fbdd8","type":"link out","z":"b192c009.52f1f","g":"8f720014.0c8dd","name":"out-manualcallcastmakkah","links":["717e413a.a5349"],"x":1815,"y":2160,"wires":[]},{"id":"13a693b5.92c5ec","type":"comment","z":"b192c009.52f1f","g":"8f720014.0c8dd","name":"Manual call of trigger cast for Makkah/Madinah Live","info":"","x":1360,"y":2000,"wires":[]},{"id":"799108f0.41bb28","type":"api-call-service","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Turn ON","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"turn_on","entityId":"media_player.chromecast","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1060,"y":1340,"wires":[["124eef07.c54df1"]]},{"id":"79dfebef.0f8044","type":"change","z":"b192c009.52f1f","g":"22cc95d.eb1396a","name":"set","rules":[{"t":"change","p":"payload.hadtih_en","pt":"msg","from":"<...>","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload.hadtih_ar","pt":"msg","from":"<...>","fromt":"re","to":"","tot":"str"},{"t":"change","p":"payload.hadtih_en","pt":"msg","from":"<.>","fromt":"re","to":"","tot":"str"},{"t":"change","p":"payload.hadtih_en","pt":"msg","from":"<.>","fromt":"re","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":835,"y":2640,"wires":[["20d9593d.682a16"]],"l":false},{"id":"a6f0b09e.7dfd2","type":"delay","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1060,"y":1100,"wires":[["cdc3643e.25f498","ac9c1347.cae03","c25108a8.993cc8"]]},{"id":"59da3820.b2d318","type":"api-call-service","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Prompt Tutup TV","server":"","version":3,"debugenabled":false,"service_domain":"notify","service":"all_handphones","entityId":"","data":"{\t   \"message\":\"📺 TV akan tutup dalam masa 5 minit\",\t   \"data\": {\t       \"persistent\":\"true\",\t       \"tag\": \"tutup_tv\",\t       \"sticky\": \"true\",\t       \"actions\":[\t           {\t               \"action\": \"tutuptv\",\t               \"title\": \"Tutupkan\"\t            },\t           {\t               \"action\": \"cancel_tutuptv\",\t               \"title\": \"Biarkan\"\t            }\t      ]\t    }\t  }\t","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1890,"y":1060,"wires":[[]]},{"id":"e1805de9.11402","type":"comment","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Tutup TV Selepas Azan","info":"","x":1880,"y":960,"wires":[]},{"id":"32e2cb3f.50bbe4","type":"api-call-service","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"turn_off","entityId":"","data":"{\"entity_id\":[\"media_player.lg_tv\",\"media_player.chromecast\",\"media_player.cwgtv\"]}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2320,"y":1140,"wires":[[]]},{"id":"36520c57.78e224","type":"api-call-service","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Clear Notification","server":"","version":3,"debugenabled":false,"service_domain":"notify","service":"all_handphones","entityId":"","data":"{\t   \"message\":\"clear_notification\",\t   \"data\": {\t        \"tag\": \"tutup_tv\"\t    }\t  }\t\t","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2370,"y":1320,"wires":[[]]},{"id":"54a77ca8.db6e64","type":"inject","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"testing","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":2370,"y":1400,"wires":[["36520c57.78e224"]]},{"id":"71d7868c.8ce2f8","type":"delay","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1860,"y":1120,"wires":[["efeba8c4.0adf98","2c1e71d0.6c654e"]]},{"id":"ca103348.ad75d","type":"change","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1915,"y":1200,"wires":[["71d7868c.8ce2f8","36520c57.78e224"]],"l":false},{"id":"6bec99a3.efd218","type":"inject","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1880,"y":1000,"wires":[["59da3820.b2d318"]]},{"id":"efeba8c4.0adf98","type":"api-call-service","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"turn_off","entityId":"media_player.cwgtv, media_player.chromecast","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2320,"y":1060,"wires":[[]]},{"id":"b1ff6ece.3655e","type":"api-call-service","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"Prompt Presolat Broadcast","server":"","version":3,"debugenabled":false,"service_domain":"notify","service":"all_handphones","entityId":"","data":"{\t   \"message\":\"📺 Pre-solat broadcast akan dimainkan dalam 5 minit\",\t   \"data\": {\t       \"persistent\":\"true\",\t       \"tag\": \"presolat_broadcast\",\t       \"sticky\": \"true\",\t       \"actions\":[\t           {\t               \"action\": \"play_presolat_broadcast\",\t               \"title\": \"Play\"\t            },\t           {\t               \"action\": \"cancel_presolat_broadcast\",\t               \"title\": \"Cancel\"\t            }\t      ]\t    }\t  }\t","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2320,"y":1560,"wires":[[]]},{"id":"de205768.74e188","type":"comment","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"Presolat broadcast prompt","info":"","x":2750,"y":1560,"wires":[]},{"id":"82755dc7.5621f","type":"link in","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"i-presolat_broadcast","links":["81104bf2.740698"],"x":1975,"y":1640,"wires":[["b1ff6ece.3655e","74a37dc0.0bcb14"]]},{"id":"9bdd154d.867238","type":"api-call-service","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"Clear Notification","server":"","version":3,"debugenabled":false,"service_domain":"notify","service":"all_handphones","entityId":"","data":"{\t   \"message\":\"clear_notification\",\t   \"data\": {\t       \"tag\": \"presolat_broadcast\"\t    }\t  }\t\t","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2730,"y":1720,"wires":[[]]},{"id":"959e20b4.6fef5","type":"inject","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"testing","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":2710,"y":1660,"wires":[["9bdd154d.867238"]]},{"id":"74a37dc0.0bcb14","type":"delay","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2260,"y":1640,"wires":[["7b96fb1d.66d8e4"]]},{"id":"7bf0c863.e16d58","type":"change","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2175,"y":1680,"wires":[["74a37dc0.0bcb14"]],"l":false},{"id":"3fac0cec.ad6c84","type":"inject","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2040,"y":1560,"wires":[["b1ff6ece.3655e"]]},{"id":"7b96fb1d.66d8e4","type":"link out","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"out-manualcallcastmakkah","links":["717e413a.a5349"],"x":2435,"y":1640,"wires":[]},{"id":"3da66b22.ed6754","type":"api-call-service","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"Turn off Media Players","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"turn_off","entityId":"media_player.cwgtv, media_player.chromecast, media_player.lg_tv","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2740,"y":1780,"wires":[[]]},{"id":"1b33b873.4f6548","type":"api-call-service","z":"b192c009.52f1f","g":"8f720014.0c8dd","name":"Off button","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.trigger_cast_livemacamadinah","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1780,"y":2120,"wires":[[]]},{"id":"c877b636.6a9488","type":"comment","z":"b192c009.52f1f","name":"Monthly Download","info":"### ## ### \n### ## ### additional nodes\n### ## ### \n### ## ### node-red-contrib-random-item \n# Via Cronjob","x":190,"y":120,"wires":[]},{"id":"72b72987.9187c8","type":"function","z":"b192c009.52f1f","name":"Store JAKIM SOLAT Data to Flow","func":"// Waktu Solat JAKIM\n// anas-ivs. 4th August 2021\n\nvar today           = new Date();\nvar dd              = String(today.getDate()).padStart(2, '0');\nvar mm              = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!\nvar yyyy            = today.getFullYear();\nvar current_time    = today.getHours();\ntoday               = mm + '/' + dd + '/' + yyyy;\n\n// data validity check :\nvar date_validation = msg.payload.prayerTime[dd-1].date.split(\"-\");\n\n// waktu_solat_hari_ini.date is in format DD-MONTH-YYYY. Month in Malay. Lookup array to match\nvar dict_bulan_bm   = [\"Januari\", \"Februari\", \"Mac\", \"April\", \"Mei\", \"Jun\", \"Julai\", \"Ogos\", \"September\", \"October\", \"November\", \"Disember\" ];\n\nif ( dd != date_validation[0] )\n{\n    msg.topic = \"ERROR\"\n    msg.payload =\"Gagal Data Validation - Hari tak padan\"\n    return msg;\n}\nif ( dict_bulan_bm[mm-1] != date_validation[1] )\n{\n    msg.topic = \"ERROR\"\n    msg.payload =\"Gagal Data Validation - Bulan tak sama\"\n    return msg;\n}\nif ( yyyy != date_validation[2] )\n{\n    msg.topic = \"ERROR\"\n    msg.payload =\"Gagal Data Validation - Tahun dah lain ni\"\n    return msg;\n}\n\n// debugging\n// msg.date_validation = date_validation;\n// msg.data_dd = dd;\n// msg.data_mm = mm;\n// msg.data_yyyy = yyyy;\n\nif (current_time >= 20) {\n    // first check if end of month - would be unable to load data.\n    // dd > array length from JSON\n    // what do we do? ideally load next month data but for now \n    // we ignore and wait for next month data fetch call up by CRON @ midnight\n    if (parseInt(dd) > msg.payload.prayerTime.length)\n    {\n        msg.waktu_solat_hari_ini  = msg.payload.prayerTime[dd-1];\n\n    }\n    else \n    {\n    // if after 8PM, then we get tomorrow's time and update HA\n        msg.waktu_solat_hari_ini  = msg.payload.prayerTime[parseInt(dd)];\n\n    }\n    \n} \nelse {\n    // retrieve from array (day - 1)\n    msg.waktu_solat_hari_ini  = msg.payload.prayerTime[dd-1];\n}\n\n//remove seconds\nmsg.waktu_solat_hari_ini.imsak      = msg.waktu_solat_hari_ini.imsak.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.fajr       = msg.waktu_solat_hari_ini.fajr.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.syuruk     = msg.waktu_solat_hari_ini.syuruk.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.dhuhr      = msg.waktu_solat_hari_ini.dhuhr.split(\":\").splice(0,2).join(\":\"); \nmsg.waktu_solat_hari_ini.asr        = msg.waktu_solat_hari_ini.asr.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.maghrib    = msg.waktu_solat_hari_ini.maghrib.split(\":\").splice(0,2).join(\":\");\nmsg.waktu_solat_hari_ini.isha       = msg.waktu_solat_hari_ini.isha.split(\":\").splice(0,2).join(\":\");\n\n\n// since JAKIM data provides tarik hijri - we use this instead\nvar jakim_hijri         = msg.waktu_solat_hari_ini.hijri.split(\"-\");\nvar dict_bulan_islam    = ['Muharram', 'Safar', 'Rabi\\' ul-awwal', 'Rabi\\' ul-akhir', 'Jumadil-awal', 'Jumadil-akhir', 'Rejab', 'Sha\\'aban', 'Ramadan', 'Shawwal', 'Zulkaedah', 'Zulhijjah'];\nmsg.hijri_date          = jakim_hijri[2]+\" \"+dict_bulan_islam[jakim_hijri[1] - 1]+\" \"+jakim_hijri[0]+\" H\";\n\n\n// for reference in Telegram notice\nmsg.waktu_solat_api =  flow.get(\"waktu_solat_api\");\nmsg.waktu_solat_hari_ini.zone                   = msg.payload.zone;\nmsg.waktu_solat_hari_ini.data_download_date     = msg.payload.serverTime;\n\n// Store in Flow\nflow.set(\"zone\", msg.waktu_solat_hari_ini.zone);\nflow.set(\"data_download_date\", msg.waktu_solat_hari_ini.data_download_date);\nflow.set(\"waktu_imsak\", msg.waktu_solat_hari_ini.imsak);\nflow.set(\"waktu_subuh\", msg.waktu_solat_hari_ini.fajr);\nflow.set(\"waktu_syuruk\", msg.waktu_solat_hari_ini.syuruk);\nflow.set(\"waktu_zohor\", msg.waktu_solat_hari_ini.dhuhr);\nflow.set(\"waktu_asar\", msg.waktu_solat_hari_ini.asr);\nflow.set(\"waktu_maghrib\", msg.waktu_solat_hari_ini.maghrib);\nflow.set(\"waktu_isyak\", msg.waktu_solat_hari_ini.isha);\nflow.set(\"waktu_tarikh_hari\", msg.waktu_solat_hari_ini.day);\nflow.set(\"waktu_tarikh_hijri\", msg.waktu_solat_hari_ini.hijri);\nflow.set(\"waktu_tarikh_masihi\", msg.waktu_solat_hari_ini.date);\n\n//if manage to get this far meaning data is available.\n//filter topic = validated only to proceed and update solat registers\nmsg.topic = \"OK\"\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":500,"wires":[["44fe01b1.351e6","89f062ef.b3e0c"]]},{"id":"545a4ddd.e0c3d4","type":"function","z":"b192c009.52f1f","name":"Solat API and Zone","func":"\n//Define ZONE here\nconst zone_api = 'SWK02';\n\nif (flow.get(\"waktu_solat_api\")===undefined)  {\nflow.set(\"waktu_solat_api\", \"JAKIM\");\n}   \n\nlet waktu_solat_api         = flow.get(\"waktu_solat_api\");\n\nif (waktu_solat_api == \"JAKIM\")\n{\nmsg.url = \"https://www.e-solat.gov.my/index.php?r=esolatApi%2Ftakwimsolat&period=month&zone=\"+zone_api;\n}\nelse if (waktusolat_source == \"AzanPro\")\n{\n    //not yet working use JAKIM\n    //msg.url = \"http://api.azanpro.com/times/today.json?zone=\"+zone_api+\"&format=24-hour\";\n\n}\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":240,"wires":[["1b8368da.094bc7"]]},{"id":"6037208e.54784","type":"inject","z":"b192c009.52f1f","name":"Tekan sekali untuk kali pertama","props":[],"repeat":"","crontab":"","once":false,"onceDelay":"0.1","topic":"","x":250,"y":240,"wires":[["545a4ddd.e0c3d4"]]},{"id":"17261447.7fa05c","type":"debug","z":"b192c009.52f1f","name":"bulanan","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1120,"y":160,"wires":[]},{"id":"1b8368da.094bc7","type":"http request","z":"b192c009.52f1f","name":"JAKIM","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":630,"y":280,"wires":[["8cc47f84.fdc0f"]]},{"id":"cac2e18d.0473a","type":"comment","z":"b192c009.52f1f","name":"Daily Lookup and Load into Flow             ","info":"### ## ### \n### ## ### additional nodes\n### ## ### \n### ## ### node-red-contrib-random-item \n# Via Cronjob","x":230,"y":400,"wires":[]},{"id":"b318b0c4.ff895","type":"file","z":"b192c009.52f1f","name":"Save to File","filename":"/share/waktu_solat/waktu_solat_month.json","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":950,"y":220,"wires":[["17261447.7fa05c","add6f5c.7a71b08"]]},{"id":"a2e493b6.db17e","type":"inject","z":"b192c009.52f1f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"3","topic":"","payload":"1","payloadType":"num","x":290,"y":460,"wires":[["eaabfff6.c4fca"]]},{"id":"eaabfff6.c4fca","type":"file in","z":"b192c009.52f1f","name":"Retreive from File","filename":"/share/waktu_solat/waktu_solat_month.json","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":530,"y":500,"wires":[["14c50ab9.ffc0b5"]]},{"id":"14c50ab9.ffc0b5","type":"json","z":"b192c009.52f1f","name":"","property":"payload","action":"","pretty":false,"x":570,"y":540,"wires":[["72b72987.9187c8"]]},{"id":"89f062ef.b3e0c","type":"debug","z":"b192c009.52f1f","name":"harian","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":540,"wires":[]},{"id":"277ffb75.6e3b34","type":"function","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Compare Times","func":"\n// construct newmsg\nnewmsg = {};\n\n// retrieve waktu solat from flow\nlet zone                = flow.get(\"zone\");\nlet data_download_date  = flow.get(\"data_download_date\");\nlet waktu_imsak         = flow.get(\"waktu_imsak\");\nlet subuhtime           = flow.get(\"waktu_subuh\");\nlet syuruktime          = flow.get(\"waktu_syuruk\");\nlet zohortime           = flow.get(\"waktu_zohor\");\nlet asartime            = flow.get(\"waktu_asar\");\nlet maghribtime         = flow.get(\"waktu_maghrib\");\nlet isyaktime           = flow.get(\"waktu_isyak\");\n\n// define other timing variables \n// PREFERENCE: add 1 minute with delay timer later to get exact azan at the minute vs. delayed\nvar minutesToAdd=1;\n\nconst now = new Date();\nconst hours = now.getHours().toString().padStart(2,'0');\nconst minutes = now.getMinutes().toString().padStart(2,'0');\n\nconst day = now.getDate();\nconst month = now.getMonth();\nconst year = now.getFullYear();\n\nconst compared_minute = new Date(now.getTime() + minutesToAdd*60000);\nconst compared_hours = compared_minute.getHours().toString().padStart(2,'0');\nconst compared_minutes = compared_minute.getMinutes().toString().padStart(2,'0');\n\n// used time for comparing later\nconst time = `${compared_hours}:${compared_minutes}`;\n\nif (time > subuhtime && time < syuruktime)\n{\n     flow.set(\"waktusolatsekarang\", \"Subuh\");\n     flow.set(\"waktusolatberikut\", \"Syuruk\");  \n     flow.set(\"time_waktusolatberikut\", syuruktime);  \n}\nelse if (time > syuruktime && time < zohortime)\n{\n    flow.set(\"waktusolatsekarang\", \"Syuruk\");\n    flow.set(\"waktusolatberikut\", \"Zohor\"); \n    flow.set(\"time_waktusolatberikut\", zohortime);  \n}\nelse if (time > zohortime && time < asartime)\n{\n    flow.set(\"waktusolatsekarang\", \"Zohor\");\n    flow.set(\"waktusolatberikut\", \"Asar\"); \n    flow.set(\"time_waktusolatberikut\", asartime);  \n}    \nelse if (time > asartime && time < maghribtime)\n{\n    flow.set(\"waktusolatsekarang\", \"Asar\");\n    flow.set(\"waktusolatberikut\", \"Maghrib\"); \n    flow.set(\"time_waktusolatberikut\", maghribtime);  \n}        \nelse if (time > maghribtime && time < isyaktime)\n{\n    flow.set(\"waktusolatsekarang\", \"Maghrib\");\n    flow.set(\"waktusolatberikut\", \"Isyak\"); \n    flow.set(\"time_waktusolatberikut\", isyaktime);  \n}     \nelse if (time > isyaktime || time < subuhtime)\n{\n    flow.set(\"waktusolatsekarang\", \"Isyak\");\n    flow.set(\"waktusolatberikut\", \"Subuh\"); \n    flow.set(\"time_waktusolatberikut\", subuhtime);  \n} \n// else \n// {\n//     flow.set(\"waktusolatsekarang\", \"unknown\");\n//     flow.set(\"waktusolatberikut\", \"unknown\"); \n//     flow.set(\"time_waktusolatberikut\", time); \n    \n// }\n  \n\nlet waktu_solat_sekarang = flow.get(\"waktusolatsekarang\");\nlet waktu_solat_berikut = flow.get(\"waktusolatberikut\");\nlet time_waktusolat_berikut = flow.get(\"time_waktusolatberikut\");\n\n// compare time to trigger for waktu solat\nif (time === subuhtime) \n{\n    newmsg.payload = \"Subuh\";\n    flow.set(\"waktusolatsekarang\", \"Subuh\");\n    flow.set(\"waktusolatberikut\", \"Syuruk\");   \n    flow.set(\"time_waktusolatberikut\", syuruktime);\n\n} else if (time  === syuruktime) \n{\n    newmsg.payload = \"Syuruk\";\n    flow.set(\"waktusolatsekarang\", \"Syuruk\");\n    flow.set(\"waktusolatberikut\", \"Zohor\");   \n    flow.set(\"time_waktusolatberikut\", zohortime);\n} else if (time  === zohortime) \n{\n    newmsg.payload = \"Zohor\";\n    flow.set(\"waktusolatsekarang\", \"Zohor\");\n    flow.set(\"waktusolatberikut\", \"Asar\");   \n    flow.set(\"time_waktusolatberikut\", asartime);    \n} else if (time  === asartime) \n{\n    newmsg.payload = \"Asar\";\n    flow.set(\"waktusolatsekarang\", \"Asar\");\n    flow.set(\"waktusolatberikut\", \"Maghrib\");   \n    flow.set(\"time_waktusolatberikut\", maghribtime);\n} else if (time  === maghribtime) \n{\n    newmsg.payload = \"Maghrib\";\n    flow.set(\"waktusolatsekarang\", \"Maghrib\");\n    flow.set(\"waktusolatberikut\", \"Isyak\");   \n    flow.set(\"time_waktusolatberikut\", isyaktime);\n} else if (time  === isyaktime) \n{\n    newmsg.payload = \"Isyak\";\n    flow.set(\"waktusolatsekarang\", \"Isyaka\");\n    flow.set(\"waktusolatberikut\", \"Subuha\");   \n    flow.set(\"time_waktusolatberikut\", isyaktime);\n} \nelse \n{  \n    //set payload empty so following flow does not trigger\n    newmsg.payload = \"\";\n}\n\n// Calculate remaining time (FUTURE - convert to function?)\n// ________________________________________________________\n// retrieve waktu solat set in flow context (from previous runs or updated above)\n\n//time_waktusolatberikut = time_waktusolatberikut;\n\n// retrieve next solat time hour and minutes\nconst ns_time_hour  = time_waktusolat_berikut.substring(0,2);\nconst ns_time_minutes = time_waktusolat_berikut.substring(3,5);\n\n// construct new date using current time and next solat time\nconst current_time  = new Date(year,month,day,hours,minutes);\nconst nextsolat_time  = new Date(year,month,day,ns_time_hour,ns_time_minutes);\n\n// establish next day midnight/day/month/year for Subuh calculation\nvar midnight_time   = now;\nmidnight_time.setHours(24,0,0,0);\nconst ns_next_day   = midnight_time.getDate();\nconst ns_next_month = midnight_time.getMonth();\nconst ns_next_year  = midnight_time.getFullYear();\n\n// Check if current time is before midnight and Subuh is next\n\n// at midnight current hour = 0\n// hence at midnight this should not run, and isya no earlier than 1800\nif ( waktu_solat_berikut == \"Subuh\" && hours > 18  )\n{\n    // then we calculate using time difference for next day time\n    var subuh_time      = new Date(ns_next_year,ns_next_month,ns_next_day,ns_time_hour,ns_time_minutes);\n    newmsg.time_waktuberikut = msConversion(subuh_time-current_time);\n}\nelse {\n    // else (for subuh) we expect current day is equal, after midnight so day is the same.\n    // for other prayers - it would be the same.\n    newmsg.time_waktuberikut = msConversion(nextsolat_time-current_time);\n}\n\n// used for later flows as payload will be replaced.\nnewmsg.waktu_solat = newmsg.payload;\nnewmsg.waktu_solat_sekarang = waktu_solat_sekarang;\nnewmsg.waktu_solat_berikut = waktu_solat_berikut;\n\n//for debugging\nnewmsg.time = time;\nnewmsg.currentnow = now;\nnewmsg.current_hour = hours;\nnewmsg.current_time = current_time;\nnewmsg.current_time_locale = current_time.toLocaleString();\nnewmsg.nextsolat_time = nextsolat_time.toLocaleString();\nnewmsg.midnight_time = midnight_time.toLocaleString();\n\n\nreturn newmsg;\n\nfunction msConversion(millis) {\n  let sec = Math.floor(millis / 1000);\n  let hrs = Math.floor(sec / 3600);\n  sec -= hrs * 3600;\n  let min = Math.floor(sec / 60);\n  sec -= min * 60;\n\n  sec = '' + sec;\n  sec = ('00' + sec).substring(sec.length);\n\n  if (hrs > 0) {\n    min = '' + min;\n    min = ('00' + min).substring(min.length);\n    return hrs + \" jam \" + min + \" minit\";\n  }\n  else {\n    return min + \" minit\";\n  }\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":1040,"wires":[["746147b6.de9f68","8b88caa3.9776d8","1c81239f.dfd61c"]]},{"id":"4541b1d8.57bc5","type":"comment","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Minute by minute lookup","info":"### ## ### \n### ## ### additional nodes\n### ## ### \n### ## ### node-red-contrib-random-item \n# Via Cronjob","x":230,"y":960,"wires":[]},{"id":"4945c457.ae3a2c","type":"inject","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":"","topic":"","payload":"1","payloadType":"num","x":430,"y":960,"wires":[["e7de13f9.4c83f"]]},{"id":"712b7fca.e8109","type":"cronplus","z":"b192c009.52f1f","name":"Monthly Refresh","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 1 1 * ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":200,"y":300,"wires":[["545a4ddd.e0c3d4"]]},{"id":"ad5a388a.699af8","type":"ha-entity","z":"b192c009.52f1f","name":"Update Waktu Solat API","server":"","version":1,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"waktu_solat_api_update"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":true,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":210,"y":840,"wires":[["51ac6129.03bac","effa5976.3108a8"],[]]},{"id":"51ac6129.03bac","type":"delay","z":"b192c009.52f1f","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":435,"y":860,"wires":[["ce8f07e2.912aa8"]],"l":false},{"id":"ce8f07e2.912aa8","type":"api-call-service","z":"b192c009.52f1f","name":"Off button","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.waktu_solat_api_update","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":560,"y":860,"wires":[[]]},{"id":"f4cefcd7.e6dc7","type":"delay","z":"b192c009.52f1f","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":315,"y":560,"wires":[["eaabfff6.c4fca"]],"l":false},{"id":"effa5976.3108a8","type":"link out","z":"b192c009.52f1f","name":"o-trigger_solat_update","links":["5b1dea78.548f44"],"x":435,"y":800,"wires":[]},{"id":"5b1dea78.548f44","type":"link in","z":"b192c009.52f1f","name":"i-trigger_solat_update","links":["effa5976.3108a8"],"x":415,"y":180,"wires":[["545a4ddd.e0c3d4"]]},{"id":"45a9b7f2.cb00b8","type":"link in","z":"b192c009.52f1f","name":"i-trigger_solat_update","links":["add6f5c.7a71b08"],"x":235,"y":560,"wires":[["f4cefcd7.e6dc7"]]},{"id":"b3129f3.663f26","type":"cronplus","z":"b192c009.52f1f","name":"Daily Refresh - 6 Hourly","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 1 * * ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":230,"y":500,"wires":[["eaabfff6.c4fca"]]},{"id":"8cc47f84.fdc0f","type":"switch","z":"b192c009.52f1f","name":"QC","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":750,"y":280,"wires":[["b318b0c4.ff895"],["bbf03c33.abaf9","55d5387a.1e6018"]]},{"id":"bbf03c33.abaf9","type":"debug","z":"b192c009.52f1f","name":"ERROR!","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":940,"y":260,"wires":[]},{"id":"d44316b3.0bd978","type":"api-current-state","z":"b192c009.52f1f","name":"WaktuSolatEnabled","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.waktusolat_nodered","state_type":"str","blockInputOverrides":false,"outputProperties":[],"x":190,"y":780,"wires":[[],[]]},{"id":"371ec913.5f6726","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":2,"width":0,"height":0,"name":"","label":"Subuh ","format":"{{msg.payload.prayer_times.subuh}}","layout":"row-spread","x":1670,"y":400,"wires":[]},{"id":"86133ba6.a8d9f8","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"Subuh_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Subuh"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.fajr","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1420,"y":400,"wires":[["371ec913.5f6726"]]},{"id":"4c277dfb.098854","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"WaktuSolat_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Waktu Solat"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"hijri_date","stateType":"msg","attributes":[{"property":"Subuh","value":"waktu_solat_hari_ini.fajr","valueType":"msg"},{"property":"Syuruk","value":"waktu_solat_hari_ini.syuruk","valueType":"msg"},{"property":"Zohor","value":"waktu_solat_hari_ini.dhuhr","valueType":"msg"},{"property":"Asar","value":"waktu_solat_hari_ini.asr","valueType":"msg"},{"property":"Maghrib","value":"waktu_solat_hari_ini.maghrib","valueType":"msg"},{"property":"Isyak","value":"waktu_solat_hari_ini.isha","valueType":"msg"},{"property":"Zone","value":"waktu_solat_hari_ini.zone","valueType":"msg"},{"property":"Tarikh","value":"waktu_solat_hari_ini.date","valueType":"msg"},{"property":"Data Downloaded Date","value":"waktu_solat_hari_ini.data_download_date","valueType":"msg"},{"property":"API Source","value":"waktu_solat_api","valueType":"msg"},{"property":"Imsak","value":"waktu_solat_hari_ini.imsak","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1440,"y":340,"wires":[[]]},{"id":"a8edf8c6.0ac928","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":3,"width":0,"height":0,"name":"","label":"Syuruk","format":"{{msg.payload.prayer_times.syuruk}}","layout":"row-spread","x":1660,"y":460,"wires":[]},{"id":"f8af1838.d32f78","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":4,"width":0,"height":0,"name":"","label":"Zohor","format":"{{msg.payload.prayer_times.zohor}}","layout":"row-spread","x":1670,"y":520,"wires":[]},{"id":"8870a7b0.dc6df8","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":5,"width":0,"height":0,"name":"","label":"Asar","format":"{{msg.payload.prayer_times.asar}}","layout":"row-spread","x":1670,"y":580,"wires":[]},{"id":"4a67e276.26637c","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":6,"width":0,"height":0,"name":"","label":"Maghrib","format":"{{msg.payload.prayer_times.maghrib}}","layout":"row-spread","x":1660,"y":640,"wires":[]},{"id":"79962577.886d2c","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"40d45c48.fc58f4","order":7,"width":0,"height":0,"name":"","label":"Isyak","format":"{{msg.payload.prayer_times.isyak}}","layout":"row-spread","x":1670,"y":700,"wires":[]},{"id":"8475476f.84bdc8","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"Syuruk_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Syuruk"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.syuruk","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1420,"y":460,"wires":[["a8edf8c6.0ac928"]]},{"id":"ec295e23.a85c7","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"Zohor_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Zohor"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.dhuhr","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1420,"y":520,"wires":[["f8af1838.d32f78"]]},{"id":"a6f28b9d.b65af8","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"Asar_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Asar"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.asr","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1420,"y":580,"wires":[["8870a7b0.dc6df8"]]},{"id":"c8023b05.eb95b8","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"Maghrib_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Maghrib"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.maghrib","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1430,"y":640,"wires":[["4a67e276.26637c"]]},{"id":"ffbb9922.968248","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"Isyak_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Isyak"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:islam"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.isha","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1420,"y":700,"wires":[["79962577.886d2c"]]},{"id":"42ec6eeb.68c1e","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"ZoneWaktuSolat_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Zone Waktu Solat"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:home-map-marker"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.zone","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1450,"y":280,"wires":[["6f51f1a4.9d5fb"]]},{"id":"6f51f1a4.9d5fb","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":1,"width":0,"height":0,"name":"","label":"Zone","format":"{{msg.payload.zone}}","layout":"row-spread","x":1670,"y":280,"wires":[]},{"id":"78231aab.c50324","type":"ha-entity","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"TarikhWaktuSolat_NodeRedInput","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Tarikh Waktu Solat"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""}],"state":"waktu_solat_hari_ini.date","stateType":"msg","attributes":[],"resend":false,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1460,"y":220,"wires":[["1b2f2219.a0563e"]]},{"id":"1b2f2219.a0563e","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":1,"width":0,"height":0,"name":"","label":"Date ","format":"{{msg.payload.prayer_times.date}}","layout":"row-spread","x":1670,"y":220,"wires":[]},{"id":"7a213032.e050d","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":1,"width":0,"height":0,"name":"","label":"Datestamp","format":"{{msg.payload.prayer_times.datestamp}}","layout":"row-spread","x":1390,"y":180,"wires":[]},{"id":"8c7b13db.5de7c","type":"ui_text","z":"b192c009.52f1f","g":"621aaea6.50ac3","group":"a0647b57.fedc08","order":5,"width":0,"height":0,"name":"","label":"HASS Current Time","format":"{{msg.payload}}","layout":"row-spread","x":1710,"y":760,"wires":[]},{"id":"5ca1cb56.9a8594","type":"server-state-changed","z":"b192c009.52f1f","g":"621aaea6.50ac3","name":"time now","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.time","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":1380,"y":760,"wires":[["8c7b13db.5de7c"]]},{"id":"f14bd617.555d38","type":"link out","z":"b192c009.52f1f","name":"T-Covid","links":["f25c50d8.9c1e5"],"x":1115,"y":640,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"f1d9ff16.648c7","type":"template","z":"b192c009.52f1f","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"🕋 Waktu Solat bagi zon {{ waktu_solat_hari_ini.zone }} \nTarikh: {{ hijri_date }} \n{{ waktu_solat_hari_ini.date }}\n\n*Imsak*  : {{ waktu_solat_hari_ini.imsak}}\n*Subuh*  : {{ waktu_solat_hari_ini.fajr }}\n*Syuruk* : {{ waktu_solat_hari_ini.syuruk }}\n*Zohor*  : {{ waktu_solat_hari_ini.dhuhr }}\n*Asar*   : {{ waktu_solat_hari_ini.asr}}\n*Maghrib*: {{ waktu_solat_hari_ini.maghrib }}\n*Isyak*  : {{ waktu_solat_hari_ini.isha }}\n\nData download date: {{waktu_solat_hari_ini.data_download_date}}\n\n\n","output":"str","x":1000,"y":640,"wires":[["f14bd617.555d38"]]},{"id":"1fa6ec3f.49e3a4","type":"switch","z":"b192c009.52f1f","name":"","property":"telegramrequest","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":850,"y":640,"wires":[["f1d9ff16.648c7"]]},{"id":"587e7b3c.00bad4","type":"telegram command","z":"b192c009.52f1f","name":"/getwaktusolat","command":"/getwaktusolat","bot":"","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":250,"y":640,"wires":[["4d33a0ca.1a43a"],[]]},{"id":"71fe748c.fce81c","type":"link in","z":"b192c009.52f1f","name":"T-BroadcastWaktuSolat","links":["f80100ac.269b"],"x":220,"y":700,"wires":[["4d33a0ca.1a43a"]],"l":true},{"id":"4d33a0ca.1a43a","type":"change","z":"b192c009.52f1f","name":"Telegram flag","rules":[{"t":"set","p":"telegramrequest","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":660,"wires":[["eaabfff6.c4fca"]]},{"id":"780f0eb6.39ec5","type":"link out","z":"b192c009.52f1f","name":"O-TelegramP1","links":["f25c50d8.9c1e5"],"x":1175,"y":340,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"55d5387a.1e6018","type":"template","z":"b192c009.52f1f","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"⚠️⚠️⚠️🕋 Data waktu solat bulan ini gagal untuk download dari {{waktu_solat_api}}\n\nError code: {{statusCode}}","output":"str","x":960,"y":300,"wires":[["780f0eb6.39ec5"]]},{"id":"add6f5c.7a71b08","type":"link out","z":"b192c009.52f1f","name":"o-trigger_solat_update","links":["45a9b7f2.cb00b8"],"x":1175,"y":220,"wires":[]},{"id":"12c47578.5297db","type":"telegram command","z":"b192c009.52f1f","name":"/refreshwaktusolat","command":"/refreshwaktusolat","description":"","registercommand":false,"language":"","bot":"","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":190,"y":180,"wires":[["545a4ddd.e0c3d4"],[]]},{"id":"73dbc05.7ae684","type":"link in","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"i-minute-pulse","links":["e7de13f9.4c83f"],"x":145,"y":1040,"wires":[["277ffb75.6e3b34"]]},{"id":"e7de13f9.4c83f","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"o-minute-pulse","links":["73dbc05.7ae684","d659ebad.1d80a8"],"x":535,"y":960,"wires":[]},{"id":"2c1e71d0.6c654e","type":"delay","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2100,"y":1140,"wires":[["32e2cb3f.50bbe4","36520c57.78e224"]]},{"id":"44fe01b1.351e6","type":"switch","z":"b192c009.52f1f","name":"QC","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"ERROR","vt":"str"},{"t":"eq","v":"OK","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1070,"y":500,"wires":[["defed156.ef28d"],["7a213032.e050d","78231aab.c50324","42ec6eeb.68c1e","4c277dfb.098854","86133ba6.a8d9f8","8475476f.84bdc8","ec295e23.a85c7","a6f28b9d.b65af8","c8023b05.eb95b8","ffbb9922.968248","1fa6ec3f.49e3a4"]]},{"id":"defed156.ef28d","type":"template","z":"b192c009.52f1f","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"⚠️⚠️⚠️🕋 Data waktu solat hari ini gagal ditetapkan. \n\nSebabnya {{payload}}","output":"str","x":960,"y":380,"wires":[["780f0eb6.39ec5"]]},{"id":"b82459be.056f48","type":"delay","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1060,"y":1300,"wires":[["208d52d.827ddae"]]},{"id":"511b9079.f8fcb","type":"function","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Audio/Azan Subuh","func":"\n//msg.payload = \"media-source://media_source/local/azansubuh.mp3\";\nmsg.payload = \"azansubuh.mp3\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1450,"y":1120,"wires":[["8f54ce9.8394b3"]]},{"id":"ea4e5db9.99087","type":"function","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Audio/Azan Random","func":"let playlist_random = getRndInteger(1,4);\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\nswitch (playlist_random) {\n    case(1):\n        mp3_id = \"azan_malaysia_tv3.mp3\";\n        break;\n    case(2):\n        mp3_id = \"azan_malaysia_shahalam.mp3\";\n        break;\n    case(3):\n        mp3_id = \"azan_misyari_rasyid_1.mp3\";\n        break;\n    case(4):\n        mp3_id = \"azan_misyari_rasyid_2.mp3\";\n        break;\n    default:\n        mp3_id = \"azan_malaysia_tv3.mp3\";\n}\n\nmsg.payload = mp3_id;\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1440,"y":1280,"wires":[["8f54ce9.8394b3"]]},{"id":"8f54ce9.8394b3","type":"link out","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"WS Speaker Out - Audio/MP3","links":["b08e9a29.a14828","ba1a529d.24a2"],"x":1675,"y":1160,"wires":[],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"c25108a8.993cc8","type":"switch","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"","property":"waktu_solat","propertyType":"msg","rules":[{"t":"eq","v":"Subuh","vt":"str"},{"t":"neq","v":"Subuh","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1210,"y":1140,"wires":[["edaa6b5e.0aa918","511b9079.f8fcb"],["29ac26b3.c2dc6a","ea4e5db9.99087"]]},{"id":"c09e234b.c4258","type":"catch","z":"b192c009.52f1f","name":"","scope":["c89028ea.98f938","72b72987.9187c8","545a4ddd.e0c3d4","74e66f38.426cb","277ffb75.6e3b34","367f3e83.607102"],"uncaught":false,"x":750,"y":320,"wires":[["f4bf6ebd.84eee","bbf03c33.abaf9"]]},{"id":"f4bf6ebd.84eee","type":"template","z":"b192c009.52f1f","name":"Telegram Text","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"⚠️⚠️⚠️🕋 \nWaktu Solat Flow Error\nSource: {{error.source.name}}\n {{error.message}}","output":"str","x":960,"y":340,"wires":[["780f0eb6.39ec5"]]},{"id":"95706046.870b7","type":"server-events","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Event: App Notification Action","server":"","version":1,"event_type":"mobile_app_notification_action","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":1940,"y":1360,"wires":[["cc26b38a.adcfd"]]},{"id":"cc26b38a.adcfd","type":"switch","z":"b192c009.52f1f","g":"7a8ff58b.91c62c","name":"Tutup TV","property":"payload.event.tag","propertyType":"msg","rules":[{"t":"eq","v":"cancel_tutuptv","vt":"str"},{"t":"eq","v":"tutuptv","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2000,"y":1300,"wires":[["ca103348.ad75d"],["36520c57.78e224"]]},{"id":"5aefb977.b44158","type":"castv2-sender","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"Google TV","connection":"1f6c530c.e04cdd","x":2570,"y":180,"wires":[[]]},{"id":"b318ba38.2327e8","type":"link in","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"in-googletvchromecast","links":["db1127cc.ff45f8","453f964b.e5b708"],"x":2395,"y":180,"wires":[["5aefb977.b44158"]]},{"id":"19583de2.453ca2","type":"api-call-service","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"TTS","server":"","version":3,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.living_room_speaker","data":"{\"message\":\"{{payload}}\",\"cache\":\"true\",\"language\":\"id\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2810,"y":280,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"8058345.829ddc8","type":"api-call-service","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"Set Volume 0.7","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.7\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2560,"y":240,"wires":[["19583de2.453ca2"]]},{"id":"e13bdfe0.eb97f","type":"link in","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"WS Speaker In - TTS","links":["208d52d.827ddae","259600f8.a7623"],"x":2020,"y":260,"wires":[["5bd3ab66.7f3314"]],"icon":"node-red-contrib-cast/google-home-mini2.svg","l":true},{"id":"5bd3ab66.7f3314","type":"api-current-state","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"WS Not occupied","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"switch.flag_nomotion_walidstudy","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2250,"y":260,"wires":[["8058345.829ddc8"],["46354ffa.7496e"]]},{"id":"46354ffa.7496e","type":"api-call-service","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"Set Volume 0.2","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.2\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2560,"y":300,"wires":[["19583de2.453ca2"]]},{"id":"b240395f.9b6608","type":"api-call-service","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"Audio/Azan Subuh","server":"","version":3,"debugenabled":true,"service_domain":"media_player","service":"play_media","entityId":"media_player.living_room_speaker","data":"{\"media_content_id\":\"media-source://media_source/local/{{payload}}\",\"media_content_type\":\"audio/mp3\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2850,"y":380,"wires":[[]]},{"id":"ba1a529d.24a2","type":"link in","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"WS Speaker In - Audio/MP3","links":["8f54ce9.8394b3","8cf62c63.4fabb","b22d32be.52878"],"x":2000,"y":380,"wires":[["9915eec0.c99aa"]],"icon":"node-red-contrib-cast/google-home-mini2.svg","l":true},{"id":"433e9897.86b008","type":"api-call-service","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"Set Volume 0.8","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.8\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2560,"y":360,"wires":[["b240395f.9b6608"]]},{"id":"9915eec0.c99aa","type":"api-current-state","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"WS Not occupied","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"switch.flag_nomotion_walidstudy","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2250,"y":380,"wires":[["433e9897.86b008"],["a7eb50fb.d8abe"]]},{"id":"a7eb50fb.d8abe","type":"api-call-service","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"Set Volume 0.15","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room_speaker","data":"{\"volume_level\":\"0.15\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2560,"y":420,"wires":[["b240395f.9b6608"]]},{"id":"4779b8bd.a8c1d8","type":"function","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"Creating message","func":"msg.payload = {\n chatId: '#UPDATECHATIDSINI',\n type: 'message',\n content: msg.payload\n}\nmsg.payload.options = {parse_mode : \"Markdown\"};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2355,"y":520,"wires":[["d9629a0e.914068"]],"l":false},{"id":"d9629a0e.914068","type":"telegram sender","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"P1 Channel","bot":"","haserroroutput":false,"outputs":1,"x":2530,"y":560,"wires":[[]]},{"id":"f25c50d8.9c1e5","type":"link in","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"TelegramP1/message","links":["1e728149.1a3d9f","4002d28e.02073c","780f0eb6.39ec5","cdc3643e.25f498","f14bd617.555d38"],"x":2160,"y":520,"wires":[["4779b8bd.a8c1d8"]],"icon":"node-red-contrib-telegrambot/telegram_cmd.png","l":true},{"id":"570ce4f9.0d6a2c","type":"function","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"","func":"\nvar picture = {\n  content: msg.payload, // <-- check msg.payload is a buffer\n  caption: msg.message,\n  type : 'photo',\n    chatId: '#UPDATECHATIDSINI',\n}\nmsg.payload = picture;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2355,"y":600,"wires":[["d9629a0e.914068"]],"l":false},{"id":"61759b88.e98484","type":"link in","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"TelegramP1/picture","links":["e73e172.4e0b9e8"],"x":2150,"y":600,"wires":[["570ce4f9.0d6a2c"]],"icon":"node-red-contrib-telegrambot/telegram_cmd.png","l":true},{"id":"7091448e.5fb06c","type":"function","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"","func":"msg.payload = {\n chatId: '#UPDATECHATIDSINI',\n type: 'message',\n content: msg.payload\n }\nmsg.payload.options = {parse_mode : \"HTML\"};\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2355,"y":560,"wires":[["d9629a0e.914068"]],"l":false},{"id":"30701843.f92f38","type":"link in","z":"b192c009.52f1f","g":"9062f1c5.aa7c5","name":"TelegramP1/html","links":["425ca14d.eb33c"],"x":2140,"y":560,"wires":[["7091448e.5fb06c"]],"icon":"node-red-contrib-telegrambot/telegram_cmd.png","l":true},{"id":"4626302c.c7fad","type":"server-events","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"Event: App Notification Action","server":"","version":1,"event_type":"mobile_app_notification_action","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":2100,"y":1800,"wires":[["19c4226e.16936e"]]},{"id":"19c4226e.16936e","type":"switch","z":"b192c009.52f1f","g":"dbf68c7f.edcbc","name":"PreSolatBroadcast","property":"payload.event.tag","propertyType":"msg","rules":[{"t":"eq","v":"play_presolat_broadcast","vt":"str"},{"t":"eq","v":"cancel_presolat_broadcast","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2150,"y":1740,"wires":[["9bdd154d.867238"],["3da66b22.ed6754","9bdd154d.867238","7bf0c863.e16d58"]]},{"id":"74e66f38.426cb","type":"function","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Compare Times 15 minutes earlier","func":"\n// construct newmsg\nnewmsg = {};\n\n// retrieve waktu solat from flow\nlet zone                = flow.get(\"zone\");\nlet data_download_date  = flow.get(\"data_download_date\");\nlet waktu_imsak         = flow.get(\"waktu_imsak\");\nlet subuhtime           = flow.get(\"waktu_subuh\");\nlet syuruktime          = flow.get(\"waktu_syuruk\");\nlet zohortime           = flow.get(\"waktu_zohor\");\nlet asartime            = flow.get(\"waktu_asar\");\nlet maghribtime         = flow.get(\"waktu_maghrib\");\nlet isyaktime           = flow.get(\"waktu_isyak\");\n\n//add 15 minutes to current time to compare with actual to 15 minute pre info\nvar minutesToAdd        = 15;\nvar currentDate         = new Date();\nvar previousDate        = new Date(currentDate.getTime() + minutesToAdd*60000);\n\nconst prehours          = previousDate.getHours().toString().padStart(2,'0');\nconst preminutes        = previousDate.getMinutes().toString().padStart(2,'0');\nconst pretime           = `${prehours}:${preminutes}`;\n\nnewmsg.kawasan = zone;\n\n\nif (pretime === subuhtime) \n{\n    newmsg.payload = \"Subuh\";\n    newmsg.solat_time = subuhtime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === syuruktime) \n{\n    newmsg.payload = \"Syuruk\";\n    newmsg.solat_time = syuruktime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === zohortime) \n{\n    newmsg.payload = \"Zohor\";\n    newmsg.solat_time = zohortime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === asartime) \n{\n    newmsg.payload = \"Asar\";\n    newmsg.solat_time = asartime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === maghribtime) \n{\n    newmsg.payload = \"Maghrib\";\n    newmsg.solat_time = maghribtime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} else if (pretime  === isyaktime) \n{\n    newmsg.payload = \"Isyak\";\n    newmsg.solat_time = isyaktime;\n    newmsg.waktu = newmsg.payload;\n    return  newmsg;\n    \n} \n\nreturn newmsg;\n\n\n// debugging\n//return newmsg;\n//newmsg.waktu = newmsg.payload;\n//newmsg.topic = pretime;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":1540,"wires":[["c0e5a10a.1b4a1","7bde58f9.fc4918"]]},{"id":"fcf14654.85b548","type":"change","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Craft Message","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"🕌 Assalamualaikum dan perhatian. Dalam masa 15 minit lagi akan masuk waktu \" & $.payload &\" pada jam \" & $.solat_time &\" bagi zon \" & $.kawasan","tot":"jsonata"},{"t":"set","p":"data","pt":"msg","to":"$.payload ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":1620,"wires":[["4002d28e.02073c","259600f8.a7623","6e8fb92d.21aca8","20abe24.1e9aa1e","c52dbcac.54844"]]},{"id":"c0e5a10a.1b4a1","type":"switch","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Pre Solat Spesific Commands","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Subuh","vt":"str"},{"t":"eq","v":"Syuruk","vt":"str"},{"t":"eq","v":"Zohor","vt":"str"},{"t":"eq","v":"Asar","vt":"str"},{"t":"eq","v":"Maghrib","vt":"str"},{"t":"eq","v":"Isyak","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":350,"y":1720,"wires":[["fcf14654.85b548","f80100ac.269b"],[],["fcf14654.85b548"],["fcf14654.85b548"],["fcf14654.85b548","b34fbd1d.58cc8"],["fcf14654.85b548"]]},{"id":"b34fbd1d.58cc8","type":"link out","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Pre-Maghrib","links":["901dc84f.a4cdf8"],"x":750,"y":1740,"wires":[],"l":true},{"id":"1e72e30b.c9fddd","type":"delay","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1800,"wires":[["b5db9719.a92f08"]]},{"id":"b5db9719.a92f08","type":"api-call-service","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Google say","server":"","version":3,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.chromecast","data":"{\"message\":\"{{payload}}\",\"cache\":\"true\",\"language\":\"id\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"payload","valueType":"msg"}],"queue":"none","x":1410,"y":1800,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini1.svg"},{"id":"4002d28e.02073c","type":"link out","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"T-PreWaktuSolat","links":["f25c50d8.9c1e5"],"x":1055,"y":1740,"wires":[],"icon":"node-red-contrib-telegrambot/telegram.png"},{"id":"259600f8.a7623","type":"link out","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"WS Speaker Out - TTS","links":["c4134f1d.de9a5","e13bdfe0.eb97f"],"x":1055,"y":1580,"wires":[],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"f80100ac.269b","type":"link out","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Waktu Solat Broadcast","links":["42d27463.d3c9ac","71fe748c.fce81c"],"x":780,"y":1680,"wires":[],"l":true},{"id":"9ad00e7.b9d25f","type":"delay","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1260,"y":1620,"wires":[["ec033520.b1ec68"]]},{"id":"ec033520.b1ec68","type":"function","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Randomizer + Youtube","func":"let playlist_random = getRndInteger(1,5);\nvar now = new Date();\n\nnode.status({fill:\"green\",shape:\"ring\",text:\" Playlist: \"+playlist_random}); \n\n//get global variable\nvar g = global.get(\"homeassistant\");\n//get states variable\nvar states = g.homeAssistant.states;\n//get the actual entity that we want\nvar video1 = states[\"input_text.azan_streaming_link_1\"].state;\nvar video2 = states[\"input_text.azan_streaming_link_2\"].state;\nvar video3 = states[\"input_text.azan_streaming_link_3\"].state;\nvar video4 = states[\"input_text.azan_streaming_link_4\"].state;\nvar video5 = states[\"input_text.azan_streaming_link_5\"].state;\n\nswitch (playlist_random) {\n    case(1):\n        // live makkah\n        // videoid = \"YsPvZXBFJko\";\n        videoid = video1;\n        break;\n    case(2):\n        // live madinah\n        //videoid = \"ERl92J7JREg\";\n        videoid = video2;\n        break;\n    case(3):\n        // madinah playback\n        //videoid = \"kGCCzo5jYhQ\";\n        videoid = video3;\n        break;\n    case(4):\n        // surah kahfi\n        //videoid = \"-rzG4nLUq-8\";\n        videoid = video4;\n        break;\n    case(5):\n        // live makkah\n        //videoid = \"2KRh6jCWEzI\";\n        videoid = video5;\n        break\n    default:\n        videoid = \"-rzG4nLUq-8\";\n}\n\nmsg.videoid = videoid;\nmsg.playlist = playlist_random;\nmsg.triggertime = now;\n\nmsg.payload = {\n\"app\": \"YouTube\",\n\"type\": \"MEDIA\",\n\"videoId\": videoid\n};\n\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n    return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1500,"y":1620,"wires":[["d1e1ccf6.3d214","a1e4f146.707a1","453f964b.e5b708"]]},{"id":"6e8fb92d.21aca8","type":"api-call-service","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"Turn ON","server":"","version":3,"debugenabled":false,"service_domain":"media_player","service":"turn_on","entityId":"media_player.chromecast","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1080,"y":1800,"wires":[["1e72e30b.c9fddd"]]},{"id":"20abe24.1e9aa1e","type":"wake on lan","z":"b192c009.52f1f","g":"98788efd.44a6e","mac":"20:17:42:d8:4e:8f","host":"192.168.0.255","udpport":9,"name":"LGTV","x":1090,"y":1540,"wires":[]},{"id":"453f964b.e5b708","type":"link out","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"out-googletvchromecast","links":["56211c60.08f6c4","cf92c33d.6c7d5","b318ba38.2327e8"],"x":1815,"y":1620,"wires":[]},{"id":"717e413a.a5349","type":"link in","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"in-manualcallcastmakkah","links":["9b5c289.e0fbdd8","7b96fb1d.66d8e4"],"x":1335,"y":1560,"wires":[["ec033520.b1ec68"]]},{"id":"c52dbcac.54844","type":"switch","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"","property":"waktu","propertyType":"msg","rules":[{"t":"neq","v":"Isyak","vt":"str"},{"t":"eq","v":"Isyak","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1090,"y":1640,"wires":[["9ad00e7.b9d25f"],["81104bf2.740698"]]},{"id":"81104bf2.740698","type":"link out","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"o-presolat_broadcast","links":["82755dc7.5621f"],"x":1235,"y":1680,"wires":[]},{"id":"d1e1ccf6.3d214","type":"debug","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1790,"y":1680,"wires":[]},{"id":"a1e4f146.707a1","type":"ha-entity","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"PreSolat Youtube Log","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"PreSolat Youtube Log"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:youtube"},{"property":"unit_of_measurement","value":""}],"state":"playlist","stateType":"msg","attributes":[{"property":"Youtube Video","value":"videoid","valueType":"msg"},{"property":"Triggered time","value":"triggertime","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1740,"y":1560,"wires":[[]]},{"id":"7bde58f9.fc4918","type":"debug","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"PreSolat","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":680,"y":1540,"wires":[]},{"id":"d659ebad.1d80a8","type":"link in","z":"b192c009.52f1f","g":"98788efd.44a6e","name":"i-minute-pulse","links":["e7de13f9.4c83f"],"x":155,"y":1540,"wires":[["74e66f38.426cb"]]},{"id":"20e5c0979b4a7b2d","type":"comment","z":"b192c009.52f1f","name":"HA-NR-WaktuSolatJakim by anas-ivs","info":" https://github.com/anas-ivs/ https://www.facebook.com/groups/homeassistantmalaysia","x":250,"y":40,"wires":[],"icon":"node-red/feed.svg"},{"id":"cbe50c39.f38f1","type":"ui_group","name":"Quote","tab":"a0a71fdc.c283d","order":3,"disp":true,"width":6,"collapse":false},{"id":"40d45c48.fc58f4","type":"ui_group","name":"Prayer Times","tab":"a0a71fdc.c283d","order":2,"disp":true,"width":"6","collapse":false},{"id":"a0647b57.fedc08","type":"ui_group","name":"Position","tab":"a0a71fdc.c283d","order":1,"disp":true,"width":"6","collapse":false},{"id":"1f6c530c.e04cdd","type":"castv2-connection","name":"","target":"GoogleTV","host":"","port":"8009"},{"id":"a0a71fdc.c283d","type":"ui_tab","name":"Prayer Times","icon":"dashboard","disabled":false,"hidden":false}]
  • @aitalinassim Node-Red baseline flow.
  • @xsoh Gregorian to Hijri calendar convert. Added 15/6. Removed 6/8.