Automate Islamic Adhan (also called Azan or Azzan) or other prayer calls - Updated 3_24_2023 for Node-RED

Ramadan Mubarak 2023 Everyone! I have started to use Node-RED add-on for Home Assistant and I have migrated over all of my automations. I would highly recommend everyone to at least try Node-RED, as you may find it useful and enjoy it much more than using the Home Assistant automations. It is a tool that allows you to visually automate and has a lot more debugging capabilities. I have updated the instructions and shared details of how I automated the Adhan in the post below.

I would recommend watching this video to get started with Node Red. Node Red for Beginners - 2021 Edition (Using Home Assistant) - YouTube.

This post maybe very specific to certain group of people but wanted to share it anyway. At the very least, you may find this helpful to leverage for other similar scenarios.

In most middle eastern countries, the Adhan can be heard from everyone’s homes. I have elder parents who prays all the time and that is the only home automation they requested from me. Over the past few years I have tried various methods, but nothing worked all the time until I came across the amazing Home Assistant platform and the great community.

A big shout out to OJ7 (Automate Playing Adhan on Google Home (using Home Assistant) · GitHub ). This was my starting point but I had to make a lot of tweaks to have the perfect automation that has made my parents extremely happy. Please feel free to ask any questions if you are trying to implement this or something similar.

The below setup is not plug and play, you will have to tweak it based on your setup, i hope this gives you a good starting point and guidance if you decide to use it

What This Automation Does: When it is time for the prayer, in the below sequence →

  • All the media in the house is muted/paused
  • The volume of the Google Home devices is adjusted (super low for early morning ~5am prayer)
  • The Adhan plays 5 times a day at the correct prayer time. All at the same time through all the speakers (synchronized)
  • All the media in the house is un-muted/un-paused to resume previous activity and state

Updated Instructions using Node Red 3/24/2023
What you will need: Using Node Red

  • Home Assistant Setup (I am using Home Assistant 2023.3.5)
  • Node-RED Home Assistant Ad-on (I am using v.14.1.0)
  • At least one Google Home Speaker (I am using 2 Google Mini and 2 Google Home) configured

High Level Instruction:

  • Enable Node-RED Home Assistant Ad-On
  • Enable the Islamic Prayer Times component sensor (Islamic Prayer Times - Home Assistant )
  • Ensure latitude and longitude is correctly configured as the Islamic Prayer Times component will use it
  • Use your local file and place in [\hassio\config\www](file://hassio/config/www/) or use Youtube link to play any Adhan that you like, see automation section later in the post. I like (Azan by Nasir Al-Qatami - YouTube ), but you can use any other ones.
  • Copy and import the provided JSON code to your Node-RED instance and modify the nodes to use the devices in your Home Assistant Setup

Detailed Instructions: Automations can be created in many ways using Node-RED, I am still learning, so my setup may not be most efficient, but it works.

Few Notes for the Node-RED automation:

  • The first 7 nodes are base for this setup. The remaining nodes after the switch node is customized based on your preferences and your setup.
  • Turn on Fajr Volume: This node just turns on an Input Boolean which in turn activities another Node-RED automation to lower the volume of the Google Home devices, so it’s not too loud in the morning.
  • Turn on Normal Volume: This node just turns on an Input Boolean which in turn activities another Node-RED automation to adjust the volume of the Google Home devices.
  • Prayer Call Status: This node is checking the status of Input Boolean. This allows to disable the prayer call if needed for any reason.

Each prayer time has its own Node-Red swim lane. Here is the Fajr:

[{"id":"5463d2678bd36082","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Mute Bose Speakers","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"media_player","service":"volume_mute","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_speaker","media_player.home_theater_speaker","media_player.kitchen_speaker"],"data":"{\"is_volume_muted\":\"true\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1360,"y":3060,"wires":[["328432ad0f4ac3e2"]]},{"id":"328432ad0f4ac3e2","type":"delay","z":"94bf9e5c1c5edac1","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1560,"y":3060,"wires":[["8d8556f87a619ccc"]]},{"id":"c6f160c92b4fe731","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Unmute Bose Speakers","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"media_player","service":"volume_mute","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_speaker","media_player.home_theater_speaker","media_player.kitchen_speaker"],"data":"{\"is_volume_muted\":\"false\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1910,"y":3060,"wires":[[]]},{"id":"8d8556f87a619ccc","type":"delay","z":"94bf9e5c1c5edac1","name":"","pauseType":"delay","timeout":"16","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1720,"y":3060,"wires":[["c6f160c92b4fe731"]]},{"id":"cdaa1a365a65a9c4","type":"server-state-changed","z":"94bf9e5c1c5edac1","name":"Current Time","server":"969aa5f8.2b8818","version":4,"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"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":3160,"wires":[["04e6452325d5aea4","d6dffd434a0a2484"]]},{"id":"d6dffd434a0a2484","type":"api-current-state","z":"94bf9e5c1c5edac1","name":"Fajr Prayer Time","server":"969aa5f8.2b8818","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.fajr_prayer","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":260,"y":3200,"wires":[["96ab7cb55f8a718c"]]},{"id":"04e6452325d5aea4","type":"moment","z":"94bf9e5c1c5edac1","name":"format time","topic":"","input":"payload","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"","output":"payload","outputType":"msg","outTz":"America/New_York","x":250,"y":3120,"wires":[["8dfbd52afb235331"]]},{"id":"96ab7cb55f8a718c","type":"moment","z":"94bf9e5c1c5edac1","name":"format time","topic":"","input":"payload","inputType":"msg","inTz":"ETC/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"C","output":"payload","outputType":"msg","outTz":"America/New_York","x":430,"y":3200,"wires":[["8dfbd52afb235331"]]},{"id":"8dfbd52afb235331","type":"join","z":"94bf9e5c1c5edac1","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":410,"y":3140,"wires":[["f95beeafd171383c"]]},{"id":"f95beeafd171383c","type":"function","z":"94bf9e5c1c5edac1","name":"Compare Times","func":"newmsg = {};\nif (msg.payload[0] == msg.payload[1]) {\n    newmsg.payload = \"True\";\n} else {\n    newmsg.payload = \"False\";\n}\n\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":3140,"wires":[["4b2f326215257e4c"]]},{"id":"4b2f326215257e4c","type":"switch","z":"94bf9e5c1c5edac1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":3140,"wires":[["b698a8f66d666b6b"]]},{"id":"168c2b9fa1fa3c69","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Play Adhan","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"media_player","service":"play_media","areaId":[],"deviceId":[],"entityId":["media_player.basement_google","media_player.bedroom_google","media_player.green_room_google","media_player.living_room_google"],"data":"{\"media_content_id\":\"http://192.168.4.79:8123/local/Adhan1.mp3\",\"media_content_type\":\"music\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1490,"y":3120,"wires":[[]]},{"id":"b698a8f66d666b6b","type":"api-current-state","z":"94bf9e5c1c5edac1","name":"Prayer Call Status","server":"830995fe.aaa838","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.prayer_call","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":890,"y":3140,"wires":[["c91a0b302dd3079a"],["8440ccd708b16bba"]]},{"id":"8440ccd708b16bba","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Notify Poran","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_poran_phone","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Didn't play Fajr Adhan\",\"title\":\"Adhan is off\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1090,"y":3160,"wires":[[]]},{"id":"c91a0b302dd3079a","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Turn on Fajr Volume","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.fajr_volume"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1120,"y":3120,"wires":[["5463d2678bd36082","3ee4f8effb90fd47","a6ea242784c821ef"]]},{"id":"3ee4f8effb90fd47","type":"delay","z":"94bf9e5c1c5edac1","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1320,"y":3120,"wires":[["168c2b9fa1fa3c69"]]},{"id":"a6ea242784c821ef","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Mute Bedroom Fire TV","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"androidtv","service":"adb_command","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_fire_tv"],"data":"{\t   \"command\":\"adb shell input keyevent 91\"\t}\t    ","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1360,"y":3180,"wires":[["bd1669e31daa1029"]]},{"id":"4d3152bc9c391993","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Turn on Normal Volume","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.normalize_volume"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1910,"y":3180,"wires":[["f56c48ae94105cca"]]},{"id":"f56c48ae94105cca","type":"api-call-service","z":"94bf9e5c1c5edac1","name":"Unmute Bedroom Fire TV","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"androidtv","service":"adb_command","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_fire_tv"],"data":"{\t   \"command\":\"adb shell input keyevent 24\"\t}\t    ","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2170,"y":3180,"wires":[[]]},{"id":"bd1669e31daa1029","type":"delay","z":"94bf9e5c1c5edac1","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1540,"y":3180,"wires":[["4a54de784fc6a2cb"]]},{"id":"4a54de784fc6a2cb","type":"delay","z":"94bf9e5c1c5edac1","name":"","pauseType":"delay","timeout":"16","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1700,"y":3180,"wires":[["4d3152bc9c391993"]]},{"id":"830995fe.aaa838","type":"server","name":"Home Assistant","addon":true},{"id":"969aa5f8.2b8818","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Here is the Dhuhr and can be used for all remaining 3 prayers, just update the Prayer time node:

[{"id":"3cc900135ed3ee82","type":"api-call-service","z":"cd1e6a1e0daba3ed","name":"Mute Bose Speakers","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"media_player","service":"volume_mute","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_speaker","media_player.home_theater_speaker","media_player.kitchen_speaker"],"data":"{\"is_volume_muted\":\"true\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1220,"y":340,"wires":[["113f4a89ce6804c6"]]},{"id":"113f4a89ce6804c6","type":"delay","z":"cd1e6a1e0daba3ed","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1420,"y":340,"wires":[["f36ec3c80f3f131e"]]},{"id":"318e35f3b7199c9d","type":"api-call-service","z":"cd1e6a1e0daba3ed","name":"Unmute Bose Speakers","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"media_player","service":"volume_mute","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_speaker","media_player.home_theater_speaker","media_player.kitchen_speaker"],"data":"{\"is_volume_muted\":\"false\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1770,"y":340,"wires":[[]]},{"id":"f36ec3c80f3f131e","type":"delay","z":"cd1e6a1e0daba3ed","name":"","pauseType":"delay","timeout":"16","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1580,"y":340,"wires":[["318e35f3b7199c9d"]]},{"id":"69418b9dc7c120c6","type":"server-state-changed","z":"cd1e6a1e0daba3ed","name":"Current Time","server":"969aa5f8.2b8818","version":4,"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"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":460,"wires":[["f1f04648780f69d3","91f2c59eabcd6482"]]},{"id":"91f2c59eabcd6482","type":"api-current-state","z":"cd1e6a1e0daba3ed","name":"Dhuhr Prayer Time","server":"969aa5f8.2b8818","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.dhuhr_prayer","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":270,"y":500,"wires":[["386b1f643a905b2f"]]},{"id":"f1f04648780f69d3","type":"moment","z":"cd1e6a1e0daba3ed","name":"format time","topic":"","input":"payload","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"","output":"payload","outputType":"msg","outTz":"America/New_York","x":250,"y":420,"wires":[["295f718c217c8b7d"]]},{"id":"386b1f643a905b2f","type":"moment","z":"cd1e6a1e0daba3ed","name":"format time","topic":"","input":"payload","inputType":"msg","inTz":"ETC/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"C","output":"payload","outputType":"msg","outTz":"America/New_York","x":450,"y":500,"wires":[["295f718c217c8b7d"]]},{"id":"295f718c217c8b7d","type":"join","z":"cd1e6a1e0daba3ed","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":420,"wires":[["6cee74ecd96213f3"]]},{"id":"6cee74ecd96213f3","type":"function","z":"cd1e6a1e0daba3ed","name":"Compare Times","func":"newmsg = {};\nif (msg.payload[0] == msg.payload[1]) {\n    newmsg.payload = \"True\";\n} else {\n    newmsg.payload = \"False\";\n}\n\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":420,"wires":[["452da9bcf62685cf"]]},{"id":"452da9bcf62685cf","type":"switch","z":"cd1e6a1e0daba3ed","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":420,"wires":[["25500a13fce91a33"]]},{"id":"fdde78d8e41f175a","type":"api-call-service","z":"cd1e6a1e0daba3ed","name":"Play Adhan","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"media_player","service":"play_media","areaId":[],"deviceId":[],"entityId":["media_player.basement_google","media_player.bedroom_google","media_player.green_room_google","media_player.living_room_google"],"data":"{\"media_content_id\":\"http://192.168.4.79:8123/local/Adhan1.mp3\",\"media_content_type\":\"music\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1350,"y":400,"wires":[[]]},{"id":"25500a13fce91a33","type":"api-current-state","z":"cd1e6a1e0daba3ed","name":"Prayer Call Status","server":"830995fe.aaa838","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.prayer_call","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":890,"y":420,"wires":[["700dde8d06252afb","3cc900135ed3ee82","e9d978e1f9e47727"],["93fd5e59b07dfabe"]]},{"id":"93fd5e59b07dfabe","type":"api-call-service","z":"cd1e6a1e0daba3ed","name":"Notify Poran","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_poran_phone","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Didn't play Dhuhr Adhan\",\"title\":\"Adhan is off\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1090,"y":500,"wires":[[]]},{"id":"700dde8d06252afb","type":"delay","z":"cd1e6a1e0daba3ed","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1180,"y":400,"wires":[["fdde78d8e41f175a"]]},{"id":"e9d978e1f9e47727","type":"api-call-service","z":"cd1e6a1e0daba3ed","name":"Mute Bedroom Fire TV","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"androidtv","service":"adb_command","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_fire_tv"],"data":"{\t   \"command\":\"adb shell input keyevent 91\"\t}\t    ","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1200,"y":460,"wires":[["f1224abe94011093"]]},{"id":"fa8f7f421630dabb","type":"api-call-service","z":"cd1e6a1e0daba3ed","name":"Unmute Bedroom Fire TV","server":"830995fe.aaa838","version":5,"debugenabled":false,"domain":"androidtv","service":"adb_command","areaId":[],"deviceId":[],"entityId":["media_player.bedroom_fire_tv"],"data":"{\t   \"command\":\"adb shell input keyevent 24\"\t}\t    ","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1750,"y":460,"wires":[[]]},{"id":"f1224abe94011093","type":"delay","z":"cd1e6a1e0daba3ed","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1380,"y":460,"wires":[["93dd85964de9e8ae"]]},{"id":"93dd85964de9e8ae","type":"delay","z":"cd1e6a1e0daba3ed","name":"","pauseType":"delay","timeout":"16","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1540,"y":460,"wires":[["fa8f7f421630dabb"]]},{"id":"830995fe.aaa838","type":"server","name":"Home Assistant","addon":true},{"id":"969aa5f8.2b8818","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Original Post using Home Assistant Automation
**What you will need: **

  • Home Assistant Setup (I am using HASSIO v.0.87)
  • At least one Google Home Speaker (I am using 2 Google Mini and 2 Google Home) configured– Couldn’t get it to work with my Alexa devices

High Level Instruction:

  • Enable Home Assistant time_date sensor
  • Enable the Islamic Prayer Times component sensor (Islamic Prayer Times - Home Assistant )
  • Ensure latitude and longitude is correctly configured as the Islamic Prayer Times component will use it
  • Use your local file and place in [\hassio\config\www](file://hassio/config/www/) or use Youtube link to play any Adhan that you like, see automation section later in the post. I like (Azan by Nasir Al-Qatami - YouTube ), but you can use any other ones.

**Original Detailed Instructions are here Automate Islamic Adhan (also called Azan or Azzan) or other prayer calls - Updated 3_24_2023 for Node-RED - #340 by porankazi

19 Likes

Thanks for this buddy. My al fajr clock is tempermental at best. Really appreciate the effort!

Salamualikom,

Thank you brother for taking the time to find a solution for what many of us who are looking for this for a while now. i am using Hassiso 9.0 and i have setting like this but i can get Athan to play,
any help will be good thanks see below my config

# Automation for Dhuhr, Asr, Maghrib, and Isha Adhan
- action:
  - alias: ''
    data:
      entity_id: media_player.living_room   # replace with your Google Home's id
      media_content_id: http://192.168.1.76:8123/local/Adhan1.mp3   # replace with your choice of Adhan
      media_content_type: music
    service: media_extractor.play_media
  - data:
      entity_id: media_player.living_room   # replace with your Google Home's id
      volume_level: '0.7'
    service: media_player.volume_set
  alias: Adhan
  condition: []
  id: '1517693010922'
  trigger:
    - platform: template
      value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_dhuhr"), "%Y-%m-%dT%H:%M:%S")) }}'
    - platform: template
      value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_asr"), "%Y-%m-%dT%H:%M:%S")) }}'
    - platform: template
      value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_maghrib"), "%Y-%m-%dT%H:%M:%S")) }}'
    - platform: template
      value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_isha"), "%Y-%m-%dT%H:%M:%S")) }}'

# Separate Automation for Fajr Adhan
- action:
  - data:
      entity_id: media_player.living_room   # replace with your Google Home's id
      media_content_id: http://192.168.1.76:8123/local/Adhan2.mp3   # replace with your choice of Fajr Adhan
      media_content_type: music
    service: media_extractor.play_media
  - data:
      entity_id: media_player.living_room   # replace with your Google Home's id
      volume_level: '0.7'
    service: media_player.volume_set
  alias: Fajr Adhan
  condition: []
  id: '1517694139112'
  trigger:
  - platform: template
    value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_fajr"), "%Y-%m-%dT%H:%M:%S")) }}'Preformatted text

Automate Islamic Adhan-1.yaml (2.1 KB)

# Automation for Dhuhr, Asr, Maghrib, and Isha Adhan
- action:
  - alias: ''
data:
  entity_id: media_player.living_room   # replace with your Google Home's id
  media_content_id: http://192.168.1.76:8123/local/Adhan1.mp3   # replace with your choice of Adhan
  media_content_type: music
service: media_extractor.play_media
  - data:
  entity_id: media_player.living_room   # replace with your Google Home's id
  volume_level: '0.7'
service: media_player.volume_set
  alias: Adhan
  condition: []
  id: '1517693010922'
  trigger:
- platform: template
  value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_dhuhr"), "%Y-%m-%dT%H:%M:%S")) }}'
- platform: template
  value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_asr"), "%Y-%m-%dT%H:%M:%S")) }}'
- platform: template
  value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_maghrib"), "%Y-%m-%dT%H:%M:%S")) }}'
- platform: template
  value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_isha"), "%Y-%m-%dT%H:%M:%S")) }}'

# Separate Automation for Fajr Adhan
- action:
  - data:
  entity_id: media_player.living_room   # replace with your Google Home's id
  media_content_id: http://192.168.1.76:8123/local/Adhan2.mp3   # replace with your choice of Fajr Adhan
  media_content_type: music
service: media_extractor.play_media
  - data:
  entity_id: media_player.living_room   # replace with your Google Home's id
  volume_level: '0.7'
service: media_player.volume_set
  alias: Fajr Adhan
  condition: []
  id: '1517694139112'
  trigger:
  - platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_fajr"), "%Y-%m-%dT%H:%M:%S")) }}'`Preformatted text`

Hi, can you please share your configuration.yaml file entry? Also do you see the below sensors? Thank you.

thanks bro
i just figure out now every this is working
thanks for good work

Glad you got it to work. You’re welcome.

Salam Aleikum, thank you so much for this.
I’m having trouble getting the athan to fire when i use the template as a condition.
I can manually trigger the media_extractor to play the athan on my google mini, however it’s not firing when i use the template.
Could you please take a look at my setup and see what i’m doing wrong?

- id: '1554439831482'
  alias: Athan_Fajr
  trigger:
  - platform: template
    value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp(strptime(states("sensor.islamic_prayer_time_fajr"), "%Y-%m-%dT%H:%M:%S")) }}'
  condition: []
  action:
  - data:
      message: Allah Yet2abal <3
      title: Time To Pray Fajr Fam
    service: notify.fam
  - data:
      entity_id: ' media_player.living_room_speaker'
      volume_level: '0.50'
    service: media_player.volume_set
  - data:
      entity_id: media_player.living_room_speaker
      media_content_id: https://www.youtube.com/watch?v=VHcRTIcRvN8
      media_content_type: audio/youtube
    service: media_extractor.play_media

Here's a snapshot of the islamic sensors
![islamic_prayer|690x496](upload://jOqKCFBP4YV2dlY31YxCQAxQuI7.jpeg) 

Here’s my islamic_prayer_times setup in the config file

- platform: islamic_prayer_times
    calculation_method: isna
    sensors:
      - fajr
      - sunrise
      - dhuhr
      - asr
      - maghrib
      - isha
      - midnight

Thanks in advance, i appreciate all the help i can get.

Salam, I am not able to see the screenshot for your state sensors. can you please try uploading it? Also I have stopped using the media extractor component and just downloaded the youtube audio file and uploaded to my www folder. But the below service call worked for me when I used the media extractor. Another question, does the automation trigger at all and the audio doesn’t play? or the automation doesn’t trigger?

  - service: media_extractor.play_media
    data:
      entity_id: media_player.bedroom_google   # replace with your Google Home's id
      media_content_id: https://www.youtube.com/watch?v=ADLO-Hm_nCQ  # replace with your choice of Adhan
      media_content_type: audio

Media extractor works fine. it’s just the automation doesn’t trigger at all when i use the
template trigger type. if i use any type of trigger like the time template for instance, then it will trigger.
Here’s the picture, sorry about that.

Assallam. Thanks for this! Will be putting this in place ASAP.

Your code for trigger seems similar to mines except for one thing. Can you manually trigger the automation to see if it works?

Please note that you may need an extra indent before the word trigger and the dash. Sometimes those simple spaces and tabs make a difference. Please copy my code and do a side by side compares and try again.

Yes i can trigger the automation manually using a different trigger method.
The code looks fine, it was generated using the automation menu on hassio.
I have sensor.time_date configured in my config file. i wonder if it has anything to do with why this trigger is not working.

sensor:
  - platform: time_date
    display_options:
      - 'date'
      - 'time'

I had to add ‘time_date’ to my setup also.

You are right, I completely forgot that it’s not a default configuration. I’ll update my original post. Thanks.

I wonder if it’s also worth doing a documentation update for the component on the site? Although not a requirement to use it, most use cases will most probably require it.

That was it, the time_date platform options had to be included for this to work… Thank you all very much for your help. waking up to the Athan of this automation at fajr for the first time was priceless. Thanks again!

Asslamu Alaikum brothers,

Thanks all for valuable work, I have followed all instructions but yet can trigger manually but Adnan does not work automatically.

Can someone share their final configuration and automation file details.

Regards,
Bilal

Asslamu Alaikum,

Can you please share your final configuration and automation file details. I am having difficulty to automate these triggers.

Regards,
Bilal