Islamic Prayer Times Notifications (On mobile device and Media Player like Alexa)

This is an automation that uses the official ‘Islamic Prayer Time’ integration in Home Assistant to send a notification to your mobile device of choice (provided that you have Home Assistant application set up on it) and plays the Athan sound on a media player device (like Alexa or Google) from a music service that you are subscribed to.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Prayer Time Notification
  description: Notification at the time of the islamic prayers. PLEASE make sure to install 'Islamic Prayer Times' integration before you use this blueprint.
  domain: automation
  input:
    Mobile_to_Notify:
      name: Mobile Device to notify
      description: Device needs to run the official Home Assistant app to receive
        notifications.
      default: ''
      selector:
        device:
          integration: mobile_app
    Media_Player_to_Notify:
      name: Media Player to play Athan
      description: Choose Media player device to play the Athan.
      selector:
        entity:
          domain: media_player
    Athan_Media:
      name: Athan Media
      description: Name of the playlist that contains the Athan sound.
    Music_Service:
      name: Music Service
      description: Name of the music service you are subscribed to.
      selector:
        select:
          options:
            - APPLE_MUSIC
            - AMAZON_MUSIC
            - SPOTIFY
            - audio/mp4
            - audio/mpeg
            - custom

trigger:
  - platform: time
    at: sensor.fajr_prayer
    id: Fajr
  - platform: time
    id: Duhr
    at: sensor.dhuhr_prayer
  - platform: time
    id: Asr
    at: sensor.asr_prayer
  - platform: time
    at: sensor.maghrib_prayer
    id: Maghrib
  - platform: time
    at: sensor.isha_prayer
    id: Isha
condition: []
action:
  - choose:
    - conditions:
      - condition: trigger
        id: Fajr
      sequence:
      - type: notify
        domain: mobile_app
        device_id: !input 'Mobile_to_Notify'
        title: 🕌 Prayer Time 🕌
        message:  حان الآن موعد صلاة الفجر
    - conditions:
      - condition: trigger
        id: Duhr
      sequence:
      - type: notify
        domain: mobile_app
        device_id: !input 'Mobile_to_Notify'
        title: 🕌 Prayer Time 🕌
        message: حان الآن موعد صلاة الظهر
      - service: media_player.play_media
        target:
          entity_id: !input 'Media_Player_to_Notify'
        data:
          media_content_id: !input 'Athan_Media'
          media_content_type: !input 'Music_Service'
    - conditions:
      - condition: trigger
        id: Asr
      sequence:
      - type: notify
        domain: mobile_app
        device_id: !input 'Mobile_to_Notify'
        title: 🕌 Prayer Time 🕌
        message: حان الآن موعد صلاة العصر
      - service: media_player.play_media
        target:
          entity_id: !input 'Media_Player_to_Notify'
        data:
          media_content_id: !input 'Athan_Media'
          media_content_type: !input 'Music_Service'
    - conditions:
      - condition: trigger
        id: Maghrib
      sequence:
      - type: notify
        domain: mobile_app
        device_id: !input 'Mobile_to_Notify'
        title: 🕌 Prayer Time 🕌
        message: حان الآن موعد صلاة المغرب
      - service: media_player.play_media
        target:
          entity_id: !input 'Media_Player_to_Notify'
        data:
          media_content_id: !input 'Athan_Media'
          media_content_type: !input 'Music_Service'
    - conditions:
      - condition: trigger
        id: Isha
      sequence:
      - type: notify
        domain: mobile_app
        device_id: !input 'Mobile_to_Notify'
        title: 🕌 Prayer Time 🕌
        message: حان الآن موعد صلاة العشاء
      - service: media_player.play_media
        target:
          entity_id: !input 'Media_Player_to_Notify'
        data:
          media_content_id: !input 'Athan_Media'
          media_content_type: !input 'Music_Service'
    default: []
mode: single
4 Likes

For all of the scheduled prayer times, it sends a notification and plays to the media_player, except for the first prayer time where it only sends a notification.

Is that intentional? (Because the first prayer time is very early?)

Yes, it is intentional :grinning: A mobile notification only should be appropariate.

could i get some help with this? everything works except at the very end. the google home beeps as if its going to play/stream something but no sound comes. any idea what the last step could be?

Do you have the Adhan file saved in your HA storage?

i dont think so. doesn’t this just stream it instead of doing it locally though?

1 Like

No you have to download media file to local storage then play during automation

could you link a quick tutorial on doing that? i’ve never done anything with local storage/files

You need to install the add-on samba share, so you can browse through the local files inside HA.
After you have downloaded the mp3 file, you need to place it on config/www directory and point your config to that place.

Hi

Could you please eloborate on this?

I have an Adhan MP3 file saved in a folder but unsure how to point to it. Also, it asks for a music service which seems to be mandatory

I have managed to get the automation to trigger, but there’s an error which says “Unable to resolve webhook ID from the device ID”

My settings look like this:

Thanks

I assume that you are trying to use google home speaker. If so, then please deleter the blue print, and reimport it again. As I upadted it for people using google.

From the Music Service you need to choose audio/mp4

Thank you, yes you are correct I’m trying to get the Adhan to play on a Nest Hub Max display

I’m no longer seeing any errors and I successfully get a notification on my mobile device

Only issue I still have is the Adhan does not play - it makes the initial noise and the screen changes as if media is about to play, but no sound from the media player

Here are my settings and the Adhan_Media.mp3 file is located in a folder called ‘www’ which sits in the Config folder

try this address

https://www.islamcan.com/audio/adhan/azan1.mp3
without the quotation marks

Hey! Thanks a lot

This worked perfectly

1 Like

Thank you shadynafie and Taras for your efforts.
I am trying to accomplish this but I am still new to home assistant and I am still learning. I would a blueprint for adthan to play all the five (including Fajr) prayers adthan on alexa echo. Is there an easy way to achieve this? Thank you all in advance for your assistance.

Assalamualaikum, thank you for the blueprint it has been super helpful as my existing solution (Automate Islamic Adhan (also called Azan or Azzan) or other prayer calls) just stopped working for some reason and i havent had time to debug it.

I’m trying to use the following link : Dropbox - Adhaan.mp3 - Simplify your life
however it doesnt seem to play.

If you have remote access to your home assistant with duckdns or other services, you can host your own adthan mp3 and then in your adthan automation list the path for it.

I’ve tried this in the past and its not worked. Do you mind sharing an example of a relative path thats worked for you?

@SuBo . I am assuming you already have alexa configured in your home assistant. If not, you need to have that first setup. The rest is easy and I can share my automation code with you if you would like that.

I’m
Confused I’ve changed the prayer time locations and they are all the same. When I check my local mosque the times aren’t the same some are later and some earlier. I chose custom but that didn’t change anything either am I
Missing something?