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

Brother Thanks for the guide, It was easy to follow and I was able to setup.
my only issue now is if i change the calculation_method from mwl to isna in the configuration.yaml file it doesn’t work. am i suppose to do anything else other than just changing the mwl to isna.

Please show us screenshots of your automation.yaml, configuration.yaml and sensor state (Developer tools -> States) for further investigation.

make sure also your longitude and latitude are corresponds to your location

1 Like

Salam Alikoum, I successfully got work this athan sensor ,and I changed calculated method to isna and I reload the scripts automations , and now the sensors didn’t get changed till restart control server, so I have to restart it every day to make it work, i updated the ha to the last version but still not working. Did someone get same issue? What’s the solution? Jazakoum allahou khayrane

My guess, without further diving in: you didn’t enable your time sensor in HA.

Enable and try again. Without enabling time_date the automation is only triggered when you restart…

Thanks for replay, this is already done in configuration.yaml . Ant it works before I added some other sensors like environemt_ canada platform, is there any log file can i check the log

I too continue to struggle with time adhan sensors updating to newer date and time. They continue to stuck there for a while and get update at some random hour in the day. That means sometimes Fajar and Duhar azan never gets played. I have all done correct set-up but still …

Please share your time and date sensor configuration.




Automation:

# Automation for Azan
- action:
  - alias: 'Azan'
    data:
      entity_id: media_player.living_room_speaker
      media_content_id: https://www.islamcan.com/audio/adhan/azan2.mp3
      media_content_type: audio/mp3
    service: media_extractor.play_media
  - data:
      entity_id: media_player.living_room_speaker
      volume_level: '0.40'
    service: media_player.volume_set
  alias: Adhan
  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")) }}'
    - 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")) }}'

Config:

homeassistant:
  name: Home
  latitude: 
  longitude: 
  unit_system: metric
  time_zone: Asia/Hong_Kong


default_config:
discovery:
media_extractor:

# Sensors
sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'time_date'
  - platform: islamic_prayer_times
    calculation_method: mwl
    sensors:
      - fajr
      - dhuhr
      - asr
      - maghrib
      - isha

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

Thank you.

@Comhen I am new to this and would like to set it up as well. Can you please also send me the list and instruction. JazakAllahu Khairunn

Sorry for the late response. Do you have a sensor.islamic_prayer_time_midnight sensor? I believe this is required for the times to be calculated correctly.

On Developer Tools, States page listing? No, I don see it there. What do I need to do to get it there please? Thank you.

Go through this documentation to add it as a sensor:

I developed a super easy version of Adhan Player for Google Home (or any device that supports chromecast). you would need a windows PC for this to install. please visit the website Adhan Play for Google Home

use my application. http://www.khanzone.com/adhan-player-for-google-home-chromecast/

What do you think about this app I developed for Windows? its a simple windows service, no need of server or anything. http://www.khanzone.com/adhan-player-for-google-home-chromecast/

I posted this in another section but no response, so trying to be more specific by posting here as it is related to Adhan automation, hope someone can help me. In below two automations, I need to set the volume back to high (many be 0.8) after playing the media. How can I do that here please? I tried few but they all give error when I validate so I think I am not getting the correct handling of this. The issue is as I play this media at lower volume, they remain lower and if I ask Google Home anything then the volume is very soft as a result. I have to give a high volume command first to hear properly. Thank you for the help.

- action:
  - alias: Azan
    data:
      entity_id: media_player.living_room_speaker
      media_content_id: http://192.168.1.2:8123/local/azans/azan.mp3
      media_content_type: audio/mp3
    service: media_extractor.play_media
  - data:
      entity_id: media_player.living_room_speaker
      volume_level: '0.40'
    service: media_player.volume_set
  alias: Adhan
  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")) +2700 }}'
  - 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")) +240 }}'
  - 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")) }}'
  id: 9ca0514bf8b1402ab763cdf778ebb183
- action:
  - alias: Fajar Azan
    data:
      entity_id: media_player.living_room_speaker
      media_content_id: http://192.168.1.2:8123/local/azans/azanfajar.mp3
      media_content_type: audio/mp3
    service: media_extractor.play_media
  - data:
      entity_id: media_player.living_room_speaker
      volume_level: '0.20'
    service: media_player.volume_set
  alias: Fajar Adhan
  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")) }}'
  id: 408790ff27bd488eada204a2166c8952
- alias: Restart HA
  trigger:
    platform: time
    at: 01:00:00
  action:
  - service: homeassistant.restart
  id: 858b38330af54550b57292db1d6c9b08
- id: '1576029466626'
  alias: A Home
  description: ''
  trigger:
  - entity_id: person.a_ashraf
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      message: A has reached home
    service: notify.yinghome
- id: '1576030193568'
  alias: Naheed Home
  description: ''
  trigger:
  - entity_id: person.atique_ashraf
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      message: Atique has reached home
    service: notify.yinghome
- id: '1576030285677'
  alias: Mobina Home
  description: ''
  trigger:
  - entity_id: person.m_i
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      message: M has reached home
    service: notify.yinghome
- id: '1576030362693'
  alias: F Home
  description: ''
  trigger:
  - entity_id: person.f_ashraf
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      message: F has reached home
    service: notify.yinghome
1 Like

Ma shallah , Amazing work , I had little issue with commas in copying the automation and template but hamdullah , my TTS device is ALEXA no Azan yet am also seeking ways to connect also to HomePod
This my 1st ever comment :slight_smile:
jazakum allah khair

1 Like

has this issue been resolved for you

Yes working fine. I had to add more time_date sensors.