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

Thank you Comhen, would you mind answering another question, I have been researching can you make like a checklist I would need

I hear I may need like a Ethernet cable, usb, sd card, and so on is that true and if so is there anything else I should purchase for starting this. Thank you again

My Fajr adhan didnā€™t work again this morning. I checked the timing in HA and it shows the following:

06%20am

Itā€™s showing 2019-05-31 but itā€™s 2019-06-01 here today!

Ay idea how to fix this? Other adhan times seem to work fineā€¦

How did you name each of the 7 different Azan wav files so that it is randomly chosen?

Iā€™ve sent you a PM, with the details.
I didnā€™t want to post here as this thread is Azan related question.

send the automations.yaml file

It worked fine this morning. It has been working fine since I first installed, only the last couple had stopped for some reason but I did some cleanup with my setup as I had duplicate time_date sensors (i.e. time_date_2, etc) and did a full host reboot, been fine since.

Didnā€™t expect the duplicate sensors would have made any difference, weirdā€¦

Hi,
azan1.wav
azan2.wav and so on, thatā€™s why

/home/pi/sounds/azan/azan{{'{0:d}'.format(range(1, 8)|random)}}.wav"

it will randomly choose any from 1 to 7, if you have more just change the range

Thank you, much appreciated

there was some problems with the Adhan API site, it should be back to normal

1 Like
salah_fajr:
        friendly_name: "Sensor 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 }}

this will show time HH:MM, if you still need it

2 Likes

Can someone please explain input boolean, why itā€™s used here? Does it sync the audio via multiple google home speakers without any delay?
I currently have it setup without input boolean and itā€™s working but there is a slight delay between the speakers. Very small delay but enough to notice it.
Is it even possible to have multiple speakers sync like they are coming from a single source without any delay?

I have to do this for each salah?

yep this is because each salah has its own sensor or you can create anew template sensor using another template sensor salah name
or for each salah sensor you choose any of those templates and it will give you the HH:MM

           {%- set fajr = (states("sensor.islamic_prayer_time_fajr").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_fajr").split("T")[1].split(":")[1]) -%}
           {%- set dhuhr = (states("sensor.islamic_prayer_time_dhuhr").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_dhuhr").split("T")[1].split(":")[1]) -%}
           {%- set asr = (states("sensor.islamic_prayer_time_asr").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_asr").split("T")[1].split(":")[1]) -%}
           {%- set maghrib = (states("sensor.islamic_prayer_time_naghrib").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_maghrib").split("T")[1].split(":")[1]) -%}
           {%- set isha = (states("sensor.islamic_prayer_time_isha").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_isha").split("T")[1].split(":")[1]) -%}
                      

you can test them in the template manager adding lets say after any line
{{ fajr }} and see the result

So this is what i ended up with,
and work perfect
sensors.yaml

  - platform: islamic_prayer_times
    calculation_method: isna
    sensors:
      - fajr
      - sunrise
      - dhuhr
      - asr
      - maghrib
      - isha
      - midnight
      
  - platform: template
    sensors:
      salah_fajr:
        friendly_name: "Sensor Salah fajr"
        value_template: {{ (states("sensor.islamic_prayer_time_fajr").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_fajr").split("T")[1].split(":")[1])  }}

      salah_dhuhr:
        friendly_name: "Sensor Salah Dhuhr"
        value_template: {{ (states("sensor.islamic_prayer_time_dhuhr").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_dhuhr").split("T")[1].split(":")[1])}} #>

          
      salah_asr:
        friendly_name: "Sensor Salah Asr"
        value_template: {{ (states("sensor.islamic_prayer_time_asr").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_asr").split("T")[1].split(":")[1]) }}

      salah_maghrib:
        friendly_name: "Sensor Salah Maghrib"
        value_template: {{ (states("sensor.islamic_prayer_time_maghrib").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_maghrib").split("T")[1].split(":")[1]) }}

      salah_isha:
        friendly_name: "Sensor Salah isha"
        value_template: {{ (states("sensor.islamic_prayer_time_isha").split("T")[1].split(":")[0]) +':'+ (states("sensor.islamic_prayer_time_isha").split("T")[1].split(":")[1]) }}

      salah_actual:
        friendly_name: "Salah Actual"
        value_template: >
           "{%- if is_state('sensor.salah_fajr', states('sensor.time')) -%}
             Fajr
           {%- elif is_state('sensor.salah_dhuhr', states('sensor.time')) -%}
             Dhuhr
           {%- elif is_state('sensor.salah_asr', states('sensor.time')) -%}
             Asr
           {%- elif is_state('sensor.salah_maghrib', states('sensor.time')) -%}
             Maghrib
           {%- elif is_state('sensor.salah_isha', states('sensor.time')) -%}
             Isha
           {%- endif -%}"

Automation_salah.yaml


  alias: Salah nuevo
  initial_state: "on"
  trigger:

    - platform: template
      value_template: "{{ is_state('sensor.salah_fajr', states('sensor.time')) }}"
    - platform: template
      value_template: "{{ is_state('sensor.salah_dhuhr', states('sensor.time')) }}"
    - platform: template
      value_template: "{{ is_state('sensor.salah_asr', states('sensor.time')) }}"
    - platform: template
      value_template: "{{ is_state('sensor.salah_maghrib', states('sensor.time')) }}"
    - platform: template
      value_template: "{{ is_state('sensor.salah_isha', states('sensor.time')) }}"

  action:
    - service: shell_command.tts_local
      data_template:
        message: >
           "{{states('sensor.zara_greeting')}}, Esa es la NotificacĆ­on de Salah al {{ states('sensor.salah_actual')}} , Sera mejor levantarse a REZAR!."

           
    - delay:
        seconds: 0.125
           
    - service: shell_command.adan_chooser
      data_template:
        direccion: "/home/pi/sounds/azan/azan{{'{0:d}'.format(range(1, 8)|random)}}.wav"

shell_command.yaml:

  adan_chooser: /usr/bin/aplay -q "{{direccion}}"

So you can use for example sensor.salah_fajr state to display HH:MM and not time to ā€¦and so on for the others
Salam alikum

1 Like

Salem all,

I just received my raspberry pi 3 model b+ in the mail along with the google home. Is any one kind enough to take the time out to explain to me what I need to do from start to finish just solely to get this automatic Azan to work throughout my house inshallah, thank you!

Downloaded HASS.io onto my sd card and got that up and running anything else I need to put on the sd card to get this to work ? Also i am very confused when it comes to programming this if anyone can help thank you brothers and sisters

Al salam alikum,
After you put the sd to your raspberry you will have to connect it to internet using the ethernet port so it loads/updates the Hassio and dependencies, this will take something between 30min to 1 hr, then you will need to read a little bit about home assistant automations, and sensors, so you can have an idea how they work, if you have any experience with python or C/C++ would help understand.
Home assistant uses langauje calle yaml, so you create those files with yaml extentions, and they use indentation like python.
for the Adan, maybe you need a media player like google audio or sonos since you are using hassio to play your files.

Donā€™t be afraid to start, once you start things will go smooth. hope this can be a good start

1 Like

Thank you for the reply brother,

I got that far and on my computer I can see home assistant. Having little trouble going through the configure and automation files and error codes and how to word everything. Tried copy pasting some codes above but get error codes I try tweaking but still error codes

it depends if you use a separate files or all configuration on one file, my set are for separate files configurations just in case

Would you mind messaging me some screenshots of your configs and automations so I can give it a try? Thank you