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

as soon go back to home i will send you

Asslamu Alaikum,

After various tries,I have managed to make it work, now only issue is that time is not Same as our area, I need to add some delay to match local mosque time.

Can anyone help on this.

Regards,
Bilal

where you live

    #Islamic Prayer Times
##calculation_method
##(string)(Optional)The calculation method used for prayer times. Must be one of: karachi, isna, mwl, makkah.
## This platform calculates prayer times using the following calculation methods:

## University of Islamic Sciences in Karachi
## Islamic Society of North America
## Muslim World League
## Umm Al-Qura University in Makkah

#sensor:
  - platform: islamic_prayer_times
    calculation_method: karachi
    sensors:
      - fajr
      - sunrise
      - dhuhr
      - asr
      - maghrib
      - isha
      - midnight

I am living close to London and calculation method is different, there is another possibility to add delay in existing calculation methods. Still experimenting to see how can I add these delays in Automation.

Can you do this with an offset?

Hi,

I am not sure how to put offset in below code, i have tried putting this at end but it does
not work

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”)) }}’

You should just use Muslim World League calculation method, no?

#sensor:
  - platform: islamic_prayer_times
    calculation_method: mwl
    sensors:
      - fajr
      - sunrise
      - dhuhr
      - asr
      - maghrib
      - isha
      - midnight

Yes i can use that, but i want to add one hour in Asar Prayer, how can i do this?

This this for the Asr entry:

- 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")) +3600 }}'

I’m not certain this will work but the idea is to add 3600 seconds to the template for the asr sensor. Try it and see?

Aleikum Al Salam!
I’m sorry i just saw your post. You could add the delay in a script.
have your automation trigger a script and then you can add the delay in your script like this:

  1. Create a script and in the first action type add the delay like this
    image
    of course you can put anytime you want, just follow thi format HH:MM:SS.
    Then add more actions to play the athan on your favorite media player.
  2. Grab the scrip entity_id and then create an automation with all of your athan template and add this as the last action
    image
    Change the entity_id to match your script entity_id.
  3. Create another automation to reset the script by simply turning that script off again.
    you could do it by time, so after athan by 5 or 10 min then turn that script off.
    I hope this helps :slight_smile:

Thanks, it worked…

This is a great config you’ve created, wondering is it possible to input our own times on there such as if i could feed it to grab the timings from a website feed? Not sure if this is possible but worth the ask.

Asalamu Alaikum, is it possible to have code in the value template to trigger a separate automation which wakes you up for suhoor. Essentially, all I’m asking for is a modified value template for the fajr sensor but 45mins before.

Thanks

Wa’alaikum salaam bro.

Try this:

- 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")) -2700 }}'
1 Like

Thanks, That worked

1 Like

Can anyone confirm the above code works? (obviously replacing the media player with your own one). I have been testing this by manually triggering the ‘Play Adhan Bedroom’ automation but it doesn’t seem to play.

JazakhAllah khair

Assalaamu’alaikum

I have been trying to get this to work but apparently my sensor for the prayer times does not get updated to the correct date (it is showing yesterday’s prayer timings), please have a look at the screenshot below. What step am I missing?

Any help will be appreciated!

I had a similar issue once but it worked fine after I restarted my home assistant. I think it refreshes at midnight.

Anyone use the iOS HA app? I have this issue but only on iOS, on desktop chrome it shows fine. Note the time and the next prayer times.

Asalamu Alaikum, youtube has had some backend changes and no longer works. you must use a local athan file.{ "entity_id": "media_player.googlehome3540", "media_content_id": "https://hassio.local:8123/local/normaladan.mp3", "media_content_type": "music" }