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

@Meaku15 You will not be able to change anything on the sensors in the UI.
From your post you have not mentioned if you did create all the input_text from the UI under Helpers.
If you did create, you will be able to change the value of the input_text to offset accordingly.
I have provided screenshots on this post

https://community.home-assistant.io/t/adhan-automation-using-home-assistant-and-google-home-mini/135622/315?u=rr86

you need to make sure you create all 5 input_text and assign the value
input_text.offset_fajr
input_text.offset_dhuhr
input_text.offset_asr
input_text.offset_maghrib
input_text.offset_isha

I have created the helper entry. Dhuhr azan just played at the time of my local timing based on the offsets that I have set. It is much easier now. But need to do it manually daily.

Thank you so much for your post.

1 Like

Can you please help me? Azan is working on google home but not with the correct times. I have adde +300 seconds there after but is not working.

- action:
  - alias: Azan
    data:
      entity_id: media_player.googlehomemini
      media_content_id: http://xxx.xxx.xxx.xxx/local/audio/3times.mp3
      media_content_type: audio/mp3
    service: media_extractor.play_media
  - data:
      entity_id: media_player.googlehomemini
      volume_level: '0.3'
    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.dhuhr_prayer"), "%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.asr_prayer"), "%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.isha_prayer"), "%Y-%m-%dT%H:%M:%S")) +300 }}'
  id: 52f2386ead0b45f5b5493d0f12a950a9

@rr86 I’m must be doing something wrong, but how do I trigger the offset selection? Here is my setup

Edit: Okay, I figured it out, but the time sensors are not updating on lovelace.

My Islamic prayer time integration doesn’t show entities suddenly from today. anyone else facing same issue?

I’m having a hard time figuring out this error. The prayer sensors are all showing unavailable in the UI. The log shows there is an error from the config file that’s not allowing the sensors to work. Does anyone know how to resolve this? The automaton works fine when I manually execute it. I just need the prayer times to work. Thank you!

Logger: homeassistant.helpers.event
Source: helpers/template.py:353
First occurred: 5:21:15 PM (5 occurrences)
Last logged: 5:21:15 PM

Error while processing template: 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 }}")
Error while processing template: 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 }}")
Error while processing template: 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 }}")
Error while processing template: 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 }}")
Error while processing template: 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 }}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 351, in async_render
    render_result = compiled.render(kwargs)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: list object has no element 1

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 448, in async_render_to_info
    render_info._result = self.async_render(variables, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 353, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: list object has no element 1

Actually when I restarted by home assistant I am having the same issue.

its really weird, I was on 2021.2.3, I thot maybe upgrading to latest 2021.4.5 would solve, but no, still its same. Hope HA dev can look into it.

I am having the same issue. Seems like aladhan.com is blocking my ip, I can visit the site from my cell phone with wifi off, but cannot through home internet service.

Can you if this is the case for you as well?

I can’t access on cellular either. It seems the site is down…

edit: just tested with VPN from Ukraine and it actually works. So they must have implemented geoblocking??

They have a status page: https://status.islamic.network/

I sent them an email. this is the response:

" Alaykum Salaam brother Adnan,

We have had to chance DNS as we put too many queries, it would appear, through Cloudflare’s free service.

It has been over 24 hours but the new DNS entries have not fully propagated yet, so some ISPs who have not flushed their cache would still go to cloudflare and may have some problems.

You can switch your DNS resolver to AT&T(Dig web interface - online lookup tool) or any of the other resolvers who are showing zilore until the others update their systems.

My apologies.

Meezaan-ud-Din"

yes same on my side, can’t access aladhan.com from my home internet line, but from cellular i can access. Although my home provider and cellular provider are same , Du.

Hopefully the situation will resolve in a couple of days as various DNS servers update.

For now if you really need it it (for prayer calls during ramadan :slight_smile: )change your DNS on your home router to one of the ones listed on the link i sent in my previous email.

1 Like

yea, for now changed the dns on my pihole to one of the resolvers able to resolve aladhan.com.

changed my DNS to 165.87.13.129 and it’s working great. some of my other issues with other websites seem to be resolved as well. I was using 8.8.8.8 and 1.1.1.1 previously.

Yeah I posted a github issue and got the same response:

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.