Azan or Adhan automation Islamic Prayer Times

I wouldn’t use it.

Reconfigure mine and work like a charm. thank you so much. i still remember your tip
to do a little math ( 2 * 30 * 30 ) :grinning:

Hi i have the same issue, did you find any solution for it yet?

Just in case anyone was looking for this. After a lot of testing i got this results:
copy-past code in a manual card in dashbord.

show_name: true
show_icon: true
show_state: true
type: glance
entities:
  - entity: sensor.fajr_prayer
    format: time
    name: Fajr
    icon: mdi:weather-sunset-up
  - entity: sensor.dhuhr_prayer
    format: time
    name: Dhuhr
    icon: mdi:white-balance-sunny
  - entity: sensor.asr_prayer
    format: time
    name: Asr
    icon: mdi:weather-sunset
  - entity: sensor.maghrib_prayer
    format: time
    name: Maghrib
    icon: mdi:weather-sunset-down
  - entity: sensor.isha_prayer
    format: time
    name: Isha
    icon: mdi:moon-waning-crescent
state_color: false
title: Pray Time

type: entities
entities:
  - entity: sensor.fajr_prayer
    format: time
    name: Fajr
    icon: mdi:weather-sunset-up
  - entity: sensor.dhuhr_prayer
    format: time
    name: Dhuhr
    icon: mdi:white-balance-sunny
  - entity: sensor.asr_prayer
    format: time
    name: Asr
    icon: mdi:weather-sunset
  - entity: sensor.maghrib_prayer
    format: time
    name: Maghrib
    icon: mdi:weather-sunset-down
  - entity: sensor.isha_prayer
    format: time
    name: Isha
    icon: mdi:moon-waning-crescent
show_name: true
show_icon: false
show_state: true
type: glance
entities:
  - entity: sensor.fajr_prayer
    format: time
    name: الفجر
  - entity: sensor.dhuhr_prayer
    format: time
    name: الظهر
  - entity: sensor.asr_prayer
    format: time
    name: العصر
  - entity: sensor.maghrib_prayer
    format: time
    name: المغرب
  - entity: sensor.isha_prayer
    format: time
    name: العشاء
state_color: false

7 Likes

Dear All,

I have some similar problem. This is my first automation ever and not yet sure why it’s not getting triggered. I would appreciate if someone could help identifying the issue.

Here is my code:

alias: Azan Time Automation
description: ""
trigger:
  - platform: time
    at:
      - sensor.dhuhr_prayer
      - sensor.asr_prayer
      - sensor.maghrib_prayer
      - sensor.isha_prayer
condition: []
action:
  - service: media_player.turn_on
    data: {}
    target:
      device_id: 02c9112fa0822830477d21d3d36d8f9a
      area_id: living_room
      entity_id: media_player.samsung_6_series_49
  - delay:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
  - service: media_player.play_media
    target:
      entity_id: media_player.tv_samsung_6_series_49
    data:
      media_content_id: media-source://dlna_dms/avm_fritz_mediaserver/:5:audio5:part11:11:5
      media_content_type: audio/mpeg
    metadata:
      title: Adhan
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://dlna_dms
        - media_content_type: object.container
          media_content_id: "media-source://dlna_dms/avm_fritz_mediaserver/:4:cont1:20:0:0:"
        - media_content_type: object.container
          media_content_id: "media-source://dlna_dms/avm_fritz_mediaserver/:4:cont1:50:0:0:"
  - delay:
      hours: 0
      minutes: 2
      seconds: 20
      milliseconds: 0
  - service: media_player.turn_off
    data: {}
    target:
      device_id: 02c9112fa0822830477d21d3d36d8f9a
      area_id: living_room
      entity_id: media_player.samsung_6_series_49
mode: single

The action part is tested independently (using fixed time trigger) and is working. But the trigger using these sensors is not taking any effect.

Thanks
Regards

For the template trigger that triggers before each prayer… is the seconds digits format limited to 3+ characters? If I set it to 120 secs and above the automation trigger works. However, if I set it to 90 secs the automation fails to trigger. Tried it multiple times and it fails with 90 secs. If I change the 90 to 120 the automation triggers works just fine.

Though not a big deal with 30 more seconds as I have automated the whole home receiver to turn on 2 mins before each prayer and then turn it off after the prayer ends. Just curious as to why it fails on 90 secs and works on 120 secs.

So this trigger works

{{ now().timestamp() | int(0) + 120 in expand('sensor.fajr_prayer', 'sensor.dhuhr_prayer', 'sensor.asr_prayer', 'sensor.isha_prayer', 'sensor.maghrib_prayer')
    | map(attribute='state') | map('as_timestamp') | list }}

And this fails to trigger.

{{ now().timestamp() | int(0) + 90 in expand('sensor.fajr_prayer', 'sensor.dhuhr_prayer', 'sensor.asr_prayer', 'sensor.isha_prayer', 'sensor.maghrib_prayer')
    | map(attribute='state') | map('as_timestamp') | list }}

I need feedback for the easy automated azan skill/app i developed for Alexa and Google Speakers. please visit SmartAzan.com for instructions.

1 Like

Dear Tara123
I hope you will help with this automation.
I want AZAN to start 25 minutes before the AZAN sensor.
I can make it to start after but I want it before for fajr sensor. I can’t but minutes in minus :slightly_smiling_face:

alias: AZAN 1 FAJR
trigger:

  • platform: time
    at:
    • sensor.islamic_prayer_times_fajr_prayer
      action:
  • delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 0
  • data:
    volume_level: 0.62
    service: media_player.volume_set
    target:
    device_id: 5a85bf93b7f168c1e30ef635fbb6f668
    entity_id: media_player.nesthub321b
  • data:
    media_content_id: /local/azan/Fajr1.mp4
    media_content_type: Video mp4
    service: media_player.play_media
    target:
    device_id: 5a85bf93b7f168c1e30ef635fbb6f668
    entity_id: media_player.nesthub321b
    mode: single

Thank you in advance for your help :pray:

Try this version. It uses a Template Trigger that triggers when the current time is greater than or equal to the sensor’s time minus 25 minutes.

alias: AZAN 1 FAJR
trigger:
  - platform: template 
    value_template: >
      {{ now() >= states('sensor.islamic_prayer_times_fajr_prayer') | as_datetime | as_local - 
        timedelta(minutes=25) }}
condition: []
action:
  - service: media_player.volume_set
    target:
      device_id: 5a85bf93b7f168c1e30ef635fbb6f668
      entity_id: media_player.nesthub321b
    data:
      volume_level: 0.62
  - service: media_player.play_media
    target:
      device_id: 5a85bf93b7f168c1e30ef635fbb6f668
      entity_id: media_player.nesthub321b
    data:
      media_content_id: /local/azan/Fajr1.mp4
      media_content_type: Video mp4
mode: single
1 Like

Thank you very much. I will try it

I tried this automation with Isha AZAN to see if it works. Unfortunately it didn’t trigger before the time .
I can still trigger the automation manually, but it didn’t work automatically.
Maybe I will wait to see if fajr can trigger before the time or I am missing something :slightly_smiling_face:

Copy-paste the following template into the Template Editor and let me know what it reports:

{{ now() }}
{{ states('sensor.islamic_prayer_times_fajr_prayer') }}
{{ states('sensor.islamic_prayer_times_fajr_prayer') | as_datetime | as_local }}
{{ states('sensor.islamic_prayer_times_fajr_prayer') | as_datetime | as_local - timedelta(minutes=25) }}

:+1: I pasted in my template editor. I think I will wait to see what will happen tomorrow.

So what did it report?

I don’t know if you mean this

Yes, thank you, that’s exactly what I wanted to see.

  • The third line tells me that the next Fajr time is tomorrow morning at 06:58 in your timezone.
  • The last line reports 06:30 which is 28 minutes before Fajr time.

I waited for it at fajr . I didn’t hear AZAN but my original AZAN was triggered ( I made separate automation for both)

I tried with duhr AZAN with the template but nothing happen.

Do you think I should copy paste the last template ( with 3 lines) in the automation . The automation you sent to me has just the third line of the template :thinking:

Or there is another reason

Probably another reason because I tested the Template Trigger (using a different sensor) and it worked.

IT WORKS :pray::pray::pray::pray:
Thank you Very much.
:+1:

Assalamualaykum,

I’ve created a template a while back.
Thought you guys might find it beneficial inshaAllah.