Adhan automation (الأذان التلقائي للصلاة) using google home mini

Thank you very much for your assistance. I finally got done. I asked in the mushroom card section and a nice person solved as you can see in the screen shot.
image

Thank you again brothers for your work !

1 Like

I updated the Lovelace card but there is still more work to do on it!

image

1 Like

This is awesome! I liked your NOW card. Maybe you could add elapsed time since current prayer started in third line. Current prayer sensor has attribute named ‘Started’.

1 Like

Thank you brother. I like your suggestion about adding the elapsed time since current prayer started. I did not know about the attributes and had to google and learn a little bit. Hamdoullah, I figured how to implement it just like you suggested. I am still working on though to make the way I want it to be. Jazaka Allah khayran

Do you happen to know how to start this a trigger a few seconds earlier?

trigger:
  - platform: template
    value_template: >-
      {% set x = states('sensor.fajr_prayer_time') %} {{ now() >=
      today_at(strptime(x, "%I:%M %p").time()) }}
  • How to format the attribute in current_prayer sensor to show like the one in sensor.time_until_next_prayer_formatted. It currently shows as as negative.
    image

Here you go. Just change the timedelta in either seconds or minutes according to your needs.

trigger:
  - platform: template
    value_template: >-
      {% set x = states('sensor.fajr_prayer_time') %}
      {{ now() + timedelta(seconds=30) >= today_at(strptime(x, "%I:%M %p").time()) }}

1 Like

Jazaka Allah khayran. It is working exactly the way I wanted.to. Thank you very much!

1 Like

Salam

Mashallah you are so good, can you please help me.

Iam not getting the Next prayer time bar and i do get the whole date and time i just want the time.

I have the Prayer time integration so my sensors are like
sensor.islamic_prayer_times_X_prayer

it looks like this.
Uploading: prayertime and bars.PNG…

Sorry for late response, your picture is not loading, could you upload again please?

Salaam everyone,
I have been reading this thread for a while now but since this is my first real attempt at a HA customization I believe I am missing some changes since the start of this thread a few years ago now. please forgive me if I have already missed the solution to my issues as i probably didn’t understand how to implement it. Before i start with any of the custom displays i want to correct the current issues.

the main problem is that the automation is not triggering at the right time. it only works when triggered manually.
I have followed the initial post instructions as will as this video. https://www.youtube.com/watch?v=XyoQgvedZgo

Here are my current files.

Configuration.yaml

homeassistant:
  latitude: 40.21675017213367
  longitude: -75.1352620124817
  unit_system: imperial
  time_zone: America/New_York
  
default_config:
discovery:
media_extractor:
sun:

# Islamic prayer times integration
islamic_prayer_times:
    calculation_method: mwl

# Sensors
sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'time_date'
  - platform: template
    sensors:
      salah_fajr:
        friendly_name: "Salah Fajr"
        value_template: >
           {%- set a = states("sensor.islamic_prayer_times_fajr_prayer").split("T")[1].split(":")[0] -%}
           {%- set b = states("sensor.islamic_prayer_times_fajr_prayer").split("T")[1].split(":")[1] -%}
           {{ a + ":" + b }}
      salah_dhuhr:
        friendly_name: "Salah Dhuhr"
        value_template: >
           {%- set a = states("sensor.islamic_prayer_times_dhuhr_prayer").split("T")[1].split(":")[0] -%}
           {%- set b = states("sensor.islamic_prayer_times_dhuhr_prayer").split("T")[1].split(":")[1] -%}
           {{ a + ":" + b }}
      salah_asr:
        friendly_name: "Salah Asr"
        value_template: >
           {%- set a = states("sensor.islamic_prayer_times_asr_prayer").split("T")[1].split(":")[0] -%}
           {%- set b = states("sensor.islamic_prayer_times_asr_prayer").split("T")[1].split(":")[1] -%}
           {{ a + ":" + b }}
      salah_maghrib:
        friendly_name: "Salah Maghrib"
        value_template: >
           {%- set a = states("sensor.islamic_prayer_times_maghrib_prayer").split("T")[1].split(":")[0] -%}
           {%- set b = states("sensor.islamic_prayer_times_maghrib_prayer").split("T")[1].split(":")[1] -%}
           {{ a + ":" + b }}
      salah_isha:
        friendly_name: "Salah Isha"
        value_template: >
           {%- set a = states("sensor.islamic_prayer_times_isha_prayer").split("T")[1].split(":")[0] -%}
           {%- set b = states("sensor.islamic_prayer_times_isha_prayer").split("T")[1].split(":")[1] -%}
           {{ a + ":" + b }}

# Text to speech
tts:
  - platform: google_translate

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

sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_utc'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'

Automations.yaml


# Automation for 5 times Azan
- action:
  - alias: 'Azan'
    data:
      entity_id: media_player.basement_speaker, media_player.kitchen_hub
      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.basement_speaker, media_player.kitchen_hub
      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_times_fajr_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_times_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_times_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_times_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_times_isha_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

I made sure to match the sensor names that are defined in the entity list.
one issue i noticed right away was that I did not have any groups.yaml and was unable to restart HA after creating the configurations and automations files. I created one but it is currently blank. i was able to create the dashboard card manually.

i apologize if this is repetitve. and thank you for the help.

Salam aalikom brother! This post have several settings for adhan and some of them are outdated.
The simplest method I would suggest is to use the islamic integration by going to settings<devices and services<click on add integration and search for Islamic prayer times.
After that just use any automation you want. Just make sure the sensors name are matching what the islamic prayer integration created for you.
Post back if you need more help!

Salam brothers.

Ramadan is close now and i want automation for some quran and duas before the adhan.

i want automation that is let says.

If 1st ramadan play media 1 before adhan 1h and play media 2 before media 1

lets say its last day of ramadan i want to play media 1 before adhan 1h and media 2 before that, Also after adhan i want to play media 3

thats for the 30 days and i also want to add if its Ramadan and specefic day let say Sunday i want media X to be played after adhan

I am trying to use prayers times in HA. I am having difficulties since I am new to this. Do you have step by step and where the code goes.

Thanks

Can anyone help with this, I tried using the scripts in (/homeassistant/configuration.yaml) and (/homeassistant/automations.yaml) but it does not work. I also downloaded the Islamic prayer time but it did not work also. How do I make it to work where it can play the adhan on it own.

image

Does anyone have step by step instruction, appreciate all the help I am newbie to HA. Jzk

Trying to make it look like this, as one of the brother shows:

ScreenShot_5_24_2024_5_58_08_PM

Start with the youtube link in the below linked post:

It was a massive help to me. It is in Arabic and some years old but it is simple enough to guide you through the main steps. The automation is all done in UI rather than via YAML. You will, however, need to make some adjustments as the latest HA interface has changed somewhat to that shown in the video. I skipped the first 3 minutes as wasn’t relevant for me.
I have managed to set up adhan automation with time off-set for Maghrib prayer and dua after each adhan. Let me know if you still have questions after watching the video.

1 Like

Here is how I set my automation:

I have three options for the trigger; one for fajr, one for maghrib (I wanted an off set after sunset), and one for the remaining three prayers

Can you share further screen shots for 3 actions for prayers.

Also how your media player is getting played? For my media I saved it in the local file for HA. I hear the my google home mini speaker getting turned on but nothing after that.

This is for one option. The basic logic is the same for all options.

I would’ve pasted this with my previous posts but I wasn’t being allowed to post because I’m new to the community. The only change you will need to do is adjust the timer before dua - this is dependent on the length of your adhan.

My media is also local. I uploaded the media when I was creating the automation. When you select the media player / play media option, you will see a window which asks you to add media.

The media should be in the media folder. Do you have terminal & SSH installed?