Adhan automation (أذان التلقائي) using Home Assistant and Google Home Mini

Assalamu alikum
Dear aamans
I have also same problem form yesterday night . entities not showing .I have read all above comments And understand the issue .
You mean need to change the DNS entries or it wil solve with in few days .
If need to change DNS please helpe the instructions

My entities are showing up again now.

@shamseer usually DNS servers will update within hours, but sometimes it can take a while. If you are not in a real to have the entities now, leave it alone and in a day or two they will start working.

I can’t help with specific instructions, it depends on how your internet connection is set up or if you want to fix the DNS at the computer running the home assistant.

The easy way would be to change your router WAN settings to change the DNS entry automatically populated from your ISP to the at&t ip I noted above. In a week or so you can change it back or leave it alone if you don’t have a specific need to change.

The other way would be to manually change the DNS in you internet configuration for the computer running hass. But manually assigning the dns.

Looks like Google and cloud flare are resolving so most people should have entities updating without a need to change dns.

Thanks for your immediate replay .
I will wait up to 2 days and after that confirm with you the status .
If not working after 2 days I believe you will help me to fix

If anyone want to offset the prayer times by several minutes, you can use a single Template Trigger like this:

- alias: 'Example 1'
  trigger:
  - platform: template
    value_template: >
      {% set f = as_timestamp(states('sensor.fajr_prayer'))  + 300 %}
      {% set d = as_timestamp(states('sensor.dhuhr_prayer')) + 300 %}
      {% set a = as_timestamp(states('sensor.asr_prayer'))   + 300 %}
      {% set i = as_timestamp(states('sensor.isha_prayer'))  + 300 %}
      {% set m = as_timestamp(states('sensor.maghrib_prayer')) + 300 %}
      {{ now().timestamp() | int in [f, d, a, i, m] }}
  action:
  ... etc ...

It offsets each of the five prayer times by 5 minutes (300 seconds). Each prayer time’s offset can, of course, be set to whatever you want. The example adds the offset to the prayer time but, if needed, you can change it so it subtracts the offset from the time,

If you want the ability to adjust the offset time in the Lovelace UI, I suggest creating five input_number entities, one for each prayer time. The following example shows how to configure five input_numbers where each one permits setting a value between 0 and 20 minutes.


Click to reveal configuration example for input_numbers
input_number:
  fajr:
    name: 'Fajr Offset'
    min: 00
    max: 20
    step: 1
  dhuhr:
    name: 'Dhuhr Offset'
    min: 00
    max: 20
    step: 1
  asr:
    name: 'Asr Offset'
    min: 00
    max: 20
    step: 1
  isha:
    name: 'Isha Offset'
    min: 00
    max: 20
    step: 1
  Maghrib:
    name: 'Maghrib Offset'
    min: 00
    max: 20
    step: 1

Then you can use the following Template Trigger:

- alias: 'Example 2'
  trigger:
  - platform: template
    value_template: >
      {% set f = as_timestamp(states('sensor.fajr_prayer'))  + states('input_number.fajr')|int * 60 %}
      {% set d = as_timestamp(states('sensor.dhuhr_prayer')) + states('input_number.dhuhr')|int * 60 %}
      {% set a = as_timestamp(states('sensor.asr_prayer'))   + states('input_number.asr')|int * 60 %}
      {% set i = as_timestamp(states('sensor.isha_prayer'))  + states('input_number.isha')|int * 60 %}
      {% set m = as_timestamp(states('sensor.maghrib_prayer')) + states('input_number.maghrib')|int * 60 %}
      {{ now().timestamp() | int in [f, d, a, i, m] }}
  action:
  ... etc ...
1 Like

Dear aamans .
From today night it has started working for me .I didn’t do anything.
But there is one issue only .the Isha prayer time is different with Qatar actual prayer time .
Actual Isha Time 7:29 PM
BUT showing in home assistant 7:58 PM
Kindly helpe to fix the issue .
Other everything is good

@shamseer change the calculation method to one that gives the right time.

Google aladhan prayer api and read through the different methods. Change the code in config.yaml to define sensors. HTH

As salam,

I would like to know will this also work with Amazon Alexa Echo Dot?

@fshaikh15 I have made it work is Echo that’s what I am using now, it’s a bit more involved as you need to install HACS and Alexa media player. see my post on the Hanafi Islamic prayer topic here

hi, my salah times are showing UTC values. sensor.salah_fajr is UTC but sensor.fajr_prayer is correct. how can i solve this?

Hi,
for some reason now my Dhuhr Prayer Athan is not triggering, everything else is. It’s not even giving an error in the log file
anyone having the same problem

Please help, Automated adhan not working for me. No adhan has happened. I used your code.

Hi Team,

I am new to Home Assistant and following the code above but to no avail. Can someone please help on the below code:

Configuration.Yaml:
homeassistant:
latitude: -35.282001
longitude: 149.128998
elevation: 577
unit_system: metric
time_zone: Australia/Sydney

#default_config:
discovery:
media_extractor:
#sun:

sensor:
#- platform: weather_data

  • platform: time_date
    display_options:
    • ‘time’
    • ‘date’
    • ‘date_time’

    - ‘date_time_iso’

    - ‘time_date’

    - ‘time_utc’

    - ‘beat’

#- platform: islamic_prayer_times

calculation_method: makkah

#sensors:
 # - fajr
  #- dhuhr
 # - asr
  #- maghrib
  #- isha
  • platform: template
    sensors:
    salah_fajr:
    friendly_name: “Salah Fajr”
    value_template: >
    {%- set a = states(“sensor.fajr_prayer”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.fajr_prayer”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_dhuhr:
    friendly_name: “Salah Dhuhr”
    value_template: >
    {%- set a = states(“sensor.dhuhr_prayer”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.dhuhr_prayer”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_asr:
    friendly_name: “Salah Asr”
    value_template: >
    {%- set a = states(“sensor.asr_prayer”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.asr_prayer”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_maghrib:
    friendly_name: “Salah Maghrib”
    value_template: >
    {%- set a = states(“sensor.maghrib_prayer”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.maghrib_prayer”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_isha:
    friendly_name: “Salah Isha”
    value_template: >
    {%- set a = states(“sensor.isha_prayer”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.isha_prayer”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}

automation.yaml:

Automation for 4 times Azan

  • action:
    • alias: ‘Azan’
      data:
      entity_id: media_player.family_room_speaker
      media_content_id: Azan masjid e nabvi madina munawra|| beautiful voice 2021|| Azan | madina - YouTube
      media_content_type: video/youtube
      service: media_extractor.play_media
    • data:
      entity_id: media_player.family_room_speaker
      volume_level: ‘0.9’
      service: media_player.volume_set
      alias: Adhan
      condition: []
      id: ‘1517693010822’
      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 = dhuhr_prayer”), “%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 = asr_prayer”), “%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 = maghrib_prayer”), “%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 = isha_prayer”), “%Y-%m-%dT%H:%M:%S”)) }}’

Separate alarm for Fajar Azan

  • action:
    • alias: ‘FajrAzan’
      data:
      entity_id: media_player.family_room_speaker
      media_content_id: Azan e Fajar Live | Madina Live | 2021 | Masjid e Nabawi - YouTube
      media_content_type: video/youtube
      service: media_extractor.play_media
    • data:
      entity_id: media_player.family_room_speaker
      volume_level: ‘0.8’
      service: media_player.volume_set
      alias: Fajr_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 = fajr_prayer”), “%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

Even if i execute it manually, Azan is not played either on minor Google Nest Hub. Your help will be really appreciated please.

image

Even the prayer times are not correct based on the Australia/Sydney Timezone.

Alright Alhumdulilah I sorted out. All good.

Usman brother computers love to work is zulu time aka UTC/GMT. so if you convert this time to your local time it will be a correct time.

Asalamu Alaykum,
I was having the same issue (manually triggering works but automatic doesn’t work), so I copied this code but it is still not working, please advise.
JazakAllahu Khairan

alrighty, Alhumdulillah I fixed it. The sensor entity id was wrong in my “Actions” area.

Hi guys, followed the instructions but Adhan times are note accurate… I set time zone and gps coordination accordingly… changed the calculation method to isna
I should have times below as of Jun 27th…
05:00
13:02
17:12
20:54
22:14