Adhan Automation (الأذان التلقائي للصلاة) using google speaker

Hello Brothers,

I can succesfully listen Azan bij triggering manullay on my Google Home but not at the time automatically.

But i see also not the correct numbers times and i want to see the actual time instead of ago. How can i solve that?

azn

Automation for 4 times Azan

  • action:
    • alias: ‘’
      data:
      entity_id: media_player.GoogleHomeMini
      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.GoogleHomeMini
      volume_level: ‘0.4’
      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”))+3000 }}’
    • 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”))+180 }}’
    • 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 alarm for Fajar Azan

  • action:
    • alias: ‘’
      data:
      entity_id: media_player.GoogleHomeMini
      media_content_id: https://www.islamcan.com/audio/adhan/azan3.mp3
      media_content_type: audio/mp3
      service: media_extractor.play_media
    • data:
      entity_id: media_player.GoogleHomeMini
      volume_level: ‘0.4’
      service: media_player.volume_set
      alias: Adhan
      condition: []
      id: ‘1517693034922’
      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”)) }}’

Restart HA to force update Islamic Time Sensors at 1AM

  • alias: Restart HA
    trigger:
    platform: time
    at: “01:00:00”
    action:
    • service: homeassistant.restart

Islmaic Pryaer Time

  • platform: time_date
    display_options:

    • ‘time’
    • ‘date’
    • ‘date_time’
    • ‘time_date’
  • platform: islamic_prayer_times
    calculation_method: karachi
    sensors:

    • fajr
    • dhuhr
    • asr
    • maghrib
    • isha
  • platform: template
    sensors:
    salah_fajr:
    friendly_name: “Salah Fajr”
    value_template: >
    {%- set a = states(“sensor.islamic_prayer_time_fajr”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.islamic_prayer_time_fajr”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_dhuhr:
    friendly_name: “Salah Dhuhr”
    value_template: >
    {%- set a = states(“sensor.islamic_prayer_time_dhuhr”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.islamic_prayer_time_dhuhr”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_asr:
    friendly_name: “Salah Asr”
    value_template: >
    {%- set a = states(“sensor.islamic_prayer_time_asr”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.islamic_prayer_time_asr”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_maghrib:
    friendly_name: “Salah Maghrib”
    value_template: >
    {%- set a = states(“sensor.islamic_prayer_time_maghrib”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.islamic_prayer_time_maghrib”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_isha:
    friendly_name: “Salah isha”
    value_template: >
    {%- set a = states(“sensor.islamic_prayer_time_isha”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.islamic_prayer_time_isha”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}

I recommend you not using this configuration file. Please use the file that I have provided.

I see now the times but such as salah 23:03 should be on 21 o clock. Just the time calculation is wrong. Do i need to do something whit calculation, i have now this set on Karachi-> i dont understand what it is mean. I am living in Europa bruxelles time.

Then in your configuration.yaml file, change

calculation_method: karachi

to

calculation_method: mwl

Salam Alikom,

@msahar I have small issue. The accuracy of the Athan is not correct. it vary from 4~10 min difference. can this be solved?

note: I’m living in Dubai, UAE

Thanks

Please show us your automation.yaml file and tell which Athan you want to offset and by how many minutes.

i have did that now but it is now little bit correction on the times but not really exact. How can i solve that? I am using the official turkish diyanet calendar for Netherlands.

Should be this one:

Salah Times which is not correct:

@msahar

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

for offsetting, I don’t have specific as there is different every day

@msahar

I have mobile app which is almost perfect with the Athan timing here. it called Salatuk.

in your configuration.yaml file, change

calculation_method: mwl

to

calculation_method: makkah

and then restart and check timings.

modify your automation.yaml file like this

# Automation for 5 times Azan
- action:
  - alias: 'Azan'
    data:
      entity_id: media_player.GoogleHomeMini
      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.GoogleHomeMini
      volume_level: '0.5'
    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"))+2220 }}'
    - 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"))+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_asr"), "%Y-%m-%dT%H:%M:%S"))+300 }}'
    - 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"))+420 }}'
    - 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")) }}'

### Restart HA to force update Islamic Time Sensors at 1AM ###
- alias: Restart HA
  trigger: 
    platform: time
    at: "01:00:00"
  action:
    - service: homeassistant.restart

I have replaced my automation but same result, also added the card again on lowelace and HA restarted.

@Himdola It will not update on card. Just keep an eye on when Athan plays out and note timing.

After changing my configuration to makkah from nwl, the times on card now also be ok but not the same. BUT, because i have changed it to makkah, do i need to change the automation again ?

afbeelding

Jazak allahu khairan, you made us very happy hearing Azan home in Australia
Could you please teach me how to I can store my own audio azkar files to hassIO
I read your reply on a similar question before but I could not understand how or where to create config and www folders
Thank you once again

Happy to hear that you made it. You need to install ADDON File Editor and then you will be able to see a folder WWW. You have to put your audio file in that folder and make some changings in the automation.yaml file. Please come back when you have audio in your WWW folder.

1 Like

As Salaam a Likum. Firstly and foremostly - a BIG THANK YOU for creating this. Long story short, It took me about 8 hours how to setup hassio on a virtual machine and then followed your scripts to create the automation. I’ve just set it up … it played the Fajr azan just fine. Since it’s Ramadan, I wanted to go the extra mile and play Dua for sehri 45 seconds before the Fajr azan (since the play time for this dua is 20 seconds) - I figured it would be a good idea to set it up to play 45 seconds before. So as I read the entire thread, I figured if we could use the +xxxx (seconds) features to offset an azan, I figured I could use the -45 feature to offset it to PLAY BEFORE the Fajr azan. Here’e how I wrote it and IT DID NOT WORK — any suggestions?

  • NOTE: Surah Rahman played just fine, as written.

Automation for Dua for Sehri

  • action:
    • alias: ‘Play Sehri Dua’
      data:
      entity_id: media_player.office_speaker, media_player.family_room_speaker, media_player.family_room_speaker
      media_content_id: https://www.thesufi.com/Islamic-Collection/Islamic_Audio_Section/67-Islamic-Masnoon-Dua-Arabic-with-Urdu-Translation-MP3/Dua-and-Supplications--22-.mp3
      media_content_type: audio/mp3
      service: media_extractor.play_media
    • data:
      entity_id: media_player.office_speaker, media_player.family_room_speaker
      volume_level: ‘0.7’
      service: media_player.volume_set
      alias: Play Sehri Dua
      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”))-45 }}’

Automation for Surah Rahman

  • action:
    • alias: ‘Play Surah Rahman’
      data:
      entity_id: media_player.office_speaker, media_player.family_room_speaker
      media_content_id: http://www.humariweb.com/quran/ar-ur/55-(hamariweb.com).mp3
      media_content_type: audio/mp3
      service: media_extractor.play_media
    • data:
      entity_id: media_player.office_speaker, media_player.family_room_speaker
      volume_level: ‘0.7’
      service: media_player.volume_set
      alias: Play Surah Rahman
      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”))+300 }}’

Sorry! didn’t get a chance to respond back to this but it should be like this (in a list format):

entity_id:
     - media_player.my_home_mini_1
     - media_player.my_home_mini_2
     - media_player.my_home_mini_3
     - media_player.my_home_mini_4

hope this helps someone else. Although, I don’t know what the limitations are.

Salam, i did all the steps given but on the main page there is no automation box at all.

Automation box does not appear. You have to add it to your dashboard.