Summary
This blueprint pauses selected media players such as TVs, then plays the appropriate adhan, and optionally resumes selected paused media players.
No files need to be moved into your system. The adhan is stored in my GitHub and it plays it from there. If you would like to add your own adhan files you can edit the content ID path.
It looks at the following entity_ids with timestamp device class to get the adhan time. These are the default names the Islamic Prayer Times creates
sensor.fajr_prayer
sensor.dhuhr_prayer
sensor.asr_prayer
sensor.maghrib_prayer
sensor.isha_prayer
Optional features:
You can also play iftar and suhoor dua for Ramadan by adding a sensor that can tell which Islamic month it is. Here is a sensor you can use. Outputs Ramaḍān
when it is Ramadan.
sensor:
- platform: rest
name: Islamic month
resource_template: http://api.aladhan.com/v1/gToH?date={{ now().strftime("%d-%m-%Y") }}&adjustment=1
value_template: "{{ value_json.data.hijri.month.en }}"
You can also disable Fajr Adhan if needed. If you want me to add more flexibility to this I can surely add it.
If you like to use your own adhan audio files, you can upload it via media browser and enter the path, ex media-source://media_source/local/fajr_adhan.mp3
Template sensor for next prayer (optional)
Here is a quick template sensor that can give you the exact time for the next prayer.
sensor:
- platform: template
sensors:
next_prayer:
friendly_name: Next Prayer
icon_template: mdi:star-crescent
value_template: >
{% if as_timestamp(now()) > as_timestamp(states('sensor.fajr_prayer')) and as_timestamp(now()) < as_timestamp(states('sensor.dhuhr_prayer')) %}
{{ states('sensor.dhuhr_prayer') | as_timestamp | timestamp_custom('%I:%M') }}
{% elif as_timestamp(now()) > as_timestamp(states('sensor.dhuhr_prayer')) and as_timestamp(now()) < as_timestamp(states('sensor.asr_prayer')) %}
{{ states('sensor.asr_prayer') | as_timestamp | timestamp_custom('%I:%M') }}
{% elif as_timestamp(now()) > as_timestamp(states('sensor.asr_prayer')) and as_timestamp(now()) < as_timestamp(states('sensor.maghrib_prayer')) %}
{{ states('sensor.maghrib_prayer') | as_timestamp | timestamp_custom('%I:%M') }}
{% elif as_timestamp(now()) > as_timestamp(states('sensor.maghrib_prayer')) and as_timestamp(now()) < as_timestamp(states('sensor.isha_prayer')) %}
{{ states('sensor.isha_prayer') | as_timestamp | timestamp_custom('%I:%M') }}
{% else %}
{{ states('sensor.fajr_prayer') | as_timestamp | timestamp_custom('%I:%M') }}
{% endif %}
Node-Red (optional):
I use node-red and this API to get my adhan times and Islamic month because it has more institutions. You can copy and paste this into your own node-red. You will have to add the custom hass node-red component
Here is the flow for node-red, you can easily copy and paste this. it gets your approximate location via your IP. The month sensor outputs Ramaḍān
when it is Ramadan.
[{"id":"db7be88d5a2dc900","type":"moment","z":"390ae1bbd94f7550","name":"","topic":"","input":"payload","inputType":"msg","inTz":"America/Toronto","adjAmount":0,"adjType":"days","adjDir":"add","format":"","locale":"C","output":"payload","outputType":"msg","outTz":"America/Toronto","x":1220,"y":340,"wires":[["0a6c13b6cfaf4c89"]]},{"id":"10faec1c62d998be","type":"moment","z":"390ae1bbd94f7550","name":"","topic":"","input":"payload","inputType":"msg","inTz":"America/Toronto","adjAmount":0,"adjType":"days","adjDir":"add","format":"","locale":"C","output":"payload","outputType":"msg","outTz":"America/Toronto","x":1220,"y":300,"wires":[["b76a795ca3f84e83"]]},{"id":"6df686d157506556","type":"moment","z":"390ae1bbd94f7550","name":"","topic":"","input":"payload","inputType":"msg","inTz":"America/Toronto","adjAmount":0,"adjType":"days","adjDir":"add","format":"","locale":"C","output":"payload","outputType":"msg","outTz":"America/Toronto","x":1220,"y":260,"wires":[["b9c75894fde698b7"]]},{"id":"11c05c6d18c6a48d","type":"moment","z":"390ae1bbd94f7550","name":"","topic":"","input":"payload","inputType":"msg","inTz":"America/Toronto","adjAmount":0,"adjType":"days","adjDir":"add","format":"","locale":"C","output":"payload","outputType":"msg","outTz":"America/Toronto","x":1220,"y":220,"wires":[["37d683766e325bbc"]]},{"id":"d40cc4e12dbd7c18","type":"moment","z":"390ae1bbd94f7550","name":"","topic":"","input":"payload","inputType":"msg","inTz":"America/Toronto","adjAmount":0,"adjType":"days","adjDir":"add","format":"","locale":"C","output":"payload","outputType":"msg","outTz":"America/Toronto","x":1220,"y":180,"wires":[["31a1330579010b14"]]},{"id":"31a1330579010b14","type":"ha-sensor","z":"390ae1bbd94f7550","name":"Fajr","entityConfig":"52f3ed29148b67f8","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1430,"y":180,"wires":[[]]},{"id":"37d683766e325bbc","type":"ha-sensor","z":"390ae1bbd94f7550","name":"Dhuhr","entityConfig":"2d9069c745819983","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1430,"y":220,"wires":[[]]},{"id":"b9c75894fde698b7","type":"ha-sensor","z":"390ae1bbd94f7550","name":"Asr","entityConfig":"8ac00d628ff4b5fa","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1430,"y":260,"wires":[[]]},{"id":"b76a795ca3f84e83","type":"ha-sensor","z":"390ae1bbd94f7550","name":"Maghrib","entityConfig":"ae7b3e8eb05fdef3","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1435,"y":300,"wires":[[]]},{"id":"0a6c13b6cfaf4c89","type":"ha-sensor","z":"390ae1bbd94f7550","name":"Isha","entityConfig":"d18a48ea9925113f","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1430,"y":340,"wires":[[]]},{"id":"854f13d5462c4a53","type":"function","z":"390ae1bbd94f7550","name":"Filtering Fajr","func":"msg.payload = msg.payload.data.timings.Fajr\n\nreturn msg;","outputs":1,"noerr":0,"x":970,"y":180,"wires":[["d40cc4e12dbd7c18"]]},{"id":"bfbbede7124dc2db","type":"function","z":"390ae1bbd94f7550","name":"Filtering Dhuhr","func":"msg.payload = msg.payload.data.timings.Dhuhr\n\nreturn msg;","outputs":1,"noerr":0,"x":980,"y":220,"wires":[["11c05c6d18c6a48d"]]},{"id":"f36dc0089d03f672","type":"function","z":"390ae1bbd94f7550","name":"Filtering Asr","func":"msg.payload = msg.payload.data.timings.Asr\n\nreturn msg;","outputs":1,"noerr":0,"x":975,"y":260,"wires":[["6df686d157506556"]]},{"id":"0b8b352d1f57352d","type":"function","z":"390ae1bbd94f7550","name":"Filtering Maghrib","func":"msg.payload = msg.payload.data.timings.Maghrib\n\nreturn msg;","outputs":1,"noerr":0,"x":990,"y":300,"wires":[["10faec1c62d998be"]]},{"id":"88e147ef3d812f03","type":"function","z":"390ae1bbd94f7550","name":"Filtering Isha","func":"msg.payload = msg.payload.data.timings.Isha\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":975,"y":340,"wires":[["db7be88d5a2dc900"]]},{"id":"7fc1d4708583d554","type":"inject","z":"390ae1bbd94f7550","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"59 23 * * *","once":true,"onceDelay":"10","topic":"","payload":"1","payloadType":"num","x":75,"y":260,"wires":[["7c8588b3840fab5d"]]},{"id":"af37b889f3402172","type":"http request","z":"390ae1bbd94f7550","name":"Prayer Times","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":715,"y":260,"wires":[["854f13d5462c4a53","bfbbede7124dc2db","f36dc0089d03f672","0b8b352d1f57352d","88e147ef3d812f03"]]},{"id":"7c8588b3840fab5d","type":"http request","z":"390ae1bbd94f7550","name":"Get Position","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://ip-api.com/json","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":255,"y":260,"wires":[["10c253fb23a66b78"]]},{"id":"10c253fb23a66b78","type":"function","z":"390ae1bbd94f7550","name":"Inserts location ","func":"var url= \"http://api.aladhan.com/timingsByCity?city=\" + msg.payload.city + \"&country=\" + msg.payload.country + \"&method=2&school=1\";\nmsg.url = url;\n\nreturn msg;","outputs":1,"noerr":0,"x":495,"y":260,"wires":[["af37b889f3402172"]]},{"id":"675d4bce1a824c0a","type":"catch","z":"390ae1bbd94f7550","name":"","scope":["52f3ed29148b67f8","2d9069c745819983","8ac00d628ff4b5fa","ae7b3e8eb05fdef3","d18a48ea9925113f"],"uncaught":false,"x":55,"y":320,"wires":[["7c8588b3840fab5d"]]},{"id":"8727a5baac57e23d","type":"json","z":"390ae1bbd94f7550","name":"","property":"payload","action":"","pretty":false,"x":750,"y":460,"wires":[["d23b9ecc1a05324f"]]},{"id":"8b93839011aa2384","type":"function","z":"390ae1bbd94f7550","name":"Insert date","func":"msg.url = \"http://api.aladhan.com/v1/gToH?date=\" + msg.payload + \"&adjustment=2\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":460,"wires":[["d2f0176fae25da82"]]},{"id":"d2f0176fae25da82","type":"http request","z":"390ae1bbd94f7550","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":610,"y":460,"wires":[["8727a5baac57e23d"]]},{"id":"7ad751ec9bace193","type":"inject","z":"390ae1bbd94f7550","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"00 00 * * *","once":true,"onceDelay":"10","topic":"","payload":"","payloadType":"date","x":110,"y":460,"wires":[["2bafcd9712646d2d"]]},{"id":"2bafcd9712646d2d","type":"moment","z":"390ae1bbd94f7550","name":"Format date","topic":"","input":"","inputType":"msg","inTz":"America/Toronto","adjAmount":0,"adjType":"days","adjDir":"add","format":"D-MM-yyyy","locale":"C","output":"","outputType":"msg","outTz":"America/Toronto","x":270,"y":460,"wires":[["8b93839011aa2384"]]},{"id":"d23b9ecc1a05324f","type":"ha-sensor","z":"390ae1bbd94f7550","name":"Islamic Month","entityConfig":"14d6cd79d18cec58","version":0,"state":"payload.data.hijri.month.en","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":920,"y":460,"wires":[[]]},{"id":"738108efad4366df","type":"catch","z":"390ae1bbd94f7550","name":"","scope":["2bafcd9712646d2d","8b93839011aa2384","d2f0176fae25da82","8727a5baac57e23d","d23b9ecc1a05324f"],"uncaught":false,"x":90,"y":520,"wires":[["2bafcd9712646d2d"]]},{"id":"52f3ed29148b67f8","type":"ha-entity-config","server":"e2aa5a9c.ae5838","deviceConfig":"","name":"sensor config for Fajr","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Fajr"},{"property":"device_class","value":"timestamp"},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"2d9069c745819983","type":"ha-entity-config","server":"e2aa5a9c.ae5838","deviceConfig":"","name":"sensor config for Dhuhr","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Dhuhr"},{"property":"device_class","value":"timestamp"},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"8ac00d628ff4b5fa","type":"ha-entity-config","server":"e2aa5a9c.ae5838","deviceConfig":"","name":"sensor config for Asr","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Asr"},{"property":"device_class","value":"timestamp"},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"ae7b3e8eb05fdef3","type":"ha-entity-config","server":"e2aa5a9c.ae5838","deviceConfig":"","name":"sensor config for Maghrib","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Maghrib"},{"property":"device_class","value":"timestamp"},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"d18a48ea9925113f","type":"ha-entity-config","server":"e2aa5a9c.ae5838","deviceConfig":"","name":"sensor config for Isha","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Isha"},{"property":"device_class","value":"timestamp"},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"14d6cd79d18cec58","type":"ha-entity-config","server":"e2aa5a9c.ae5838","deviceConfig":"","name":"sensor config for Islamic Month","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Islamic Month"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:calendar"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"e2aa5a9c.ae5838","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]
Blueprint: