Adhan Azan Automation Home Assistant

What is wrong here, everything works now but i don’t get any notification. When i run the automation manually, it works well.

alias: OgleVakti
description: ""
trigger:
  - platform: time
    at: sensor.ogle
    id: Ogle
condition:
  - condition: trigger
    id:
      - Ogle
action:
  - data:
      message: Ogle Namazi
    action: notify.mobile_app_xxxxx
  - metadata: {}
    data:
      volume_level: 0.15
    target:
      entity_id: media_player.xxxxx
    action: media_player.volume_set
  - action: media_player.play_media
    metadata: {}
    data:
      media_content_id: http://xxxxxxxxxx:8123/local/xxx.mp3
      media_content_type: audio/mp3
    target:
      entity_id: media_player.xxxx
mode: single

Has anyone elses playback started failing after 2024.8.0?

2 Likes

I am not an expert but it looks like after action. you should issue a call of service and in this case it should be notify first and then data with message:

action:
  - service: notify.mobile_app_xxxxx
    data:
      message: Ogle Namazi
      title: πŸ•Œ Prayer Time πŸ•Œ

This is assuming you only have issue getting notification on your mobile and the adhan plays fine on your speakers

Use this format for local files.

data:
media_content_id: /local/adhan/Adhan.mp3
media_content_type: audio/mp3
target:
entity_id: media_player.receiver
action: media_player.play_media

As Salaam Mu Aliakum

Hoping someone can guide me to get the Athaan automation to work

I used to use the Islamic Prayer time integration but the Athaan times are not correct for my country, i played with all the options in the integration and not successful without using delays etc

i decided to try the scrape integration and scrape the time from the following site

Masjid Muaadh bin Jabal - Crosby

image

I was able to successfully extract the time from the site (yay) but the issue I believe is the template used does not convert the string into a datestamp and does not trigger the Athaan automation.

my scrape settings

my automation

    alias: ASR Adthaan
    trigger:
      - trigger: time
        at:
          - sensor.asr_athaan
    action:
      - data:
          volume_level: 0.5
        action: media_player.volume_set
        target:
          entity_id: media_player.living_room_speaker
      - data:
          media_content_id: https://xxxxxxxxxx:8123/local/azan3.mp3
          media_content_type: music/mp3
        action: media_player.play_media
        target:
          entity_id: media_player.living_room_speaker
      - delay: "00:00:00"
    mode:
      single

above automation works when triggering manually but does not play the athaan at the indicated time

im using the following to convert the time into a valid format but it does not identity the device class as a timestamp, when selecting timestamp in the scrape integration settings the time shows as β€˜none’

{{ today_at(value) | as_timestamp | timestamp_custom('%H:%M') }}

would appreciate any assistance, new to HA

Hi, how did you get the Hijri Date?
I cant seem to get it to work.
also, would it possible to share your YAML dashboard code?

Thanks,

It looks very nice, do you mind to share the codes and sensors. I want to built a page like yours if possible. Thank you

You can find it here:

Hi @chintito4ever -

I’m using Prayer Times Integration to get all my prayers and sensors.

All works well, and also the Dashboard is setup with times.

Would you be able to help/guide on how to get the Hijri Date\month integrated? Any leads or ideas on how to achieve this without the use of api (which was mentioned in other posts)

Idea is, if it’s Ramadan, then play Iftar/Suhoor duas

2 Likes

Hi,

Thanks for sharing the code. I got most of the stuff to work but have 3 issues

  1. Islamic date won’t show up on the top
  2. the timer bar won’t work
  3. not able to get Fajr & الفجر in separate lines

This is yaml for my card
β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™
</>type: custom:stack-in-card
cards:

  • type: custom:button-card
    variables:
    currentview: |
    [[[
    return window.location.pathname.split(β€˜/’).slice(-1);
    ]]]
    entity: sensor.islamic_day
    show_name: false
    show_state: true
    color_type: card
    card_mod:
    style: |
    ha-card {
    margin-top: 1px;
    margin-bottom: 1px;
    margin-left: 1px;
    margin-right: 10px;
    border: skyblue solid 5px !important;
    }
    styles:
    card:
    - height: 3em
    - align: center
    - font-weight: bold
    - background-color: β€œβ€
    - color: orange
  • type: custom:layout-card
    layout_type: custom:grid
    layout:
    grid-template-columns: auto 100px
    grid-template-rows: auto auto
    margin: β€œ-4px 0px -10px -4px;”
    cards:
    • type: custom:mushroom-template-card
      primary: Prayer Times | Ψ£ΩˆΩ‚Ψ§Ψͺ Ψ§Ω„Ψ΅Ω„Ψ§Ψ©
      secondary: |-
      Next Prayer: {{ states(β€˜sensor.next_prayer’) }} | Starts in {{
      states(β€˜sensor.time_until_next_prayer’) }}
      icon: mdi:mosque
      entity: sensor.next_prayer
      tap_action:
      action: none
      hold_action:
      action: none
      icon_color: blue
      fill_container: false
      multiline_secondary: false
      card_mod:
      style:
      .: |
      ha-card {
      background: none;
      box-shadow: none;
      font-style: italic;
      font-variant: small-caps;
      }
      mushroom-state-info$: |

        .container {
          --primary-text-color: rgba(255, 255, 255, 0.9);  /* White with slight transparency for high legibility */
          --secondary-text-color: rgba(255, 235, 59, 0.9);  /* A soft amber for a warm contrast */
        }
      
    • type: custom:mushroom-template-card
      primary: Now is
      secondary: β€œ{{ states(β€˜sensor.current_prayer’) }} time”
      entity: sensor.current_prayer
      tap_action:
      action: none
      hold_action:
      action: none
      icon_color: blue
      fill_container: false
      multiline_secondary: false
      card_mod:
      style:
      .: |
      ha-card {
      background: #A100ff;
      box-shadow: none;
      font-style: italic;
      font-variant: small-caps;
      font-weight: bold
      }
      mushroom-state-info$: |

        .container {
          --primary-text-color: rgba(255, 255, 255, 0.9);  /* White with slight transparency for high legibility */
          --secondary-text-color: rgba(0, 255, 206, 0.9);  /* A soft amber for a warm contrast */
          --card-secondary-font-size: 13px;
          align-items: center;
        }
      
  • type: custom:timer-bar-card
    entity: sensor.next_prayer_timer
    name: Until Next Prayer
    icon: mdi:clock
  • type: horizontal-stack
    cards:
    • type: custom:mushroom-template-card
      primary: Fajr / الفجر
      secondary: β€œ{{ states(β€˜sensor.fajr_time’) }}”
      icon: mdi:mosque
      icon_color: β€œ#Fff600”
      layout: vertical
      tap_action:
      action: more-info
      entity: sensor.current_prayer
      card_mod:
      style: |
      ha-card {
      {% if states(β€˜sensor.current_prayer’) == β€˜Fajr’ %}
      border: 1px outset green;
      background: rgba(161, 0, 255, 0.5) !important;
      {% else %}
      background: rgba(21,76,121, 0.5) !important;
      {% endif %}
      width: 75px;
      padding: 8px !important;
      margin-bottom: 5px;
      box-shadow: var(–ha-card-box-shadow) !important;
      border-radius: 15px !important;
      margin-left: auto;
      margin-right: auto;
      }
      ha-card:hover {
      background: rgba(255, 235, 59, 0.5) !important;
      border-color: orange;
      }
      ha-state-icon {
      {% if states(β€˜sensor.current_prayer’) == β€˜Fajr’ %}
      animation: spin 2s linear infinite;
      {% endif %}
      }
      @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
      }

    • type: custom:mushroom-template-card
      primary: Dhuhr
      secondary: |
      {{ states(β€˜sensor.dhuhr_time’) }}
      tap_action:
      action: more-info
      entity: sensor.current_prayer
      icon: mdi:mosque-outline
      icon_color: β€œ#Ffa800”
      layout: vertical
      card_mod:
      style:
      .: |
      ha-card {
      /* Set size and spacing of button */

          {% if states('sensor.current_prayer') == 'Dhuhr' %}
            border: 1px outset green; /* Example border color */
            background: rgba(161, 0, 255, 0.5) !important;
          {% else %}
            background: rgba(21,76,121, 0.5) !important; 
          {% endif %}
          
          width: 75px;
          --spacing: 8px;
          padding-bottom: calc(var(--spacing) * 1.718) !important;
          margin-bottom: 5px;
          /* Styling of button */
          
          
          box-shadow: var(--ha-card-box-shadow) !important;
          border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
      
          /* Center button */
          margin-left: auto;
          margin-right: auto;
          transition: all 0s;
        }
      
        /* Add subtle color on hover */
        ha-card:hover {
          background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
          border-color: orange; /* Orange border on hover */
        }
        ha-state-icon {
          {% if states('sensor.current_prayer') == 'Dhuhr' %}
            animation: spin 2s linear infinite;
          {% endif %}
        }
        @keyframes spin {
          0% {transform: rotate(0deg);}
      mushroom-state-info$: |
        .primary:after {
          content: 'Ψ§Ω„ΨΈΩ‡Ψ±';
          display: flex;
          flex-direction: column;
          color: skyblue;
        }            
        .container {               
          --secondary-text-color: rgba(238,238,228, 0.9);  /* A soft amber for a warm contrast */
          --primary-text-color: orange;
        }
      
    • type: custom:mushroom-template-card
      primary: Asr
      secondary: |
      {{ states(β€˜sensor.asr_time’) }}
      icon: mdi:mosque
      icon_color: β€œ#2fff00”
      layout: vertical
      tap_action:
      action: more-info
      entity: sensor.current_prayer
      card_mod:
      style:
      .: |
      ha-card {
      /* Set size and spacing of button */

          {% if states('sensor.current_prayer') == 'Asr' %}
            border: 1px outset green; /* Example border color */
            background: rgba(161, 0, 255, 0.5) !important;
          {% else %}
            background: rgba(21,76,121, 0.5) !important; 
          {% endif %}
          
          width: 75px;
          --spacing: 8px;
          padding-bottom: calc(var(--spacing) * 1.718) !important;
          margin-bottom: 5px;
          /* Styling of button */
          
          
          box-shadow: var(--ha-card-box-shadow) !important;
          border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
      
          /* Center button */
          margin-left: auto;
          margin-right: auto;
          transition: all 0s;
        }
      
        /* Add subtle color on hover */
        ha-card:hover {
          background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
          border-color: orange; /* Orange border on hover */
        }
        ha-state-icon {
          {% if states('sensor.current_prayer') == 'Asr' %}
            animation: spin 2s linear infinite;
          {% endif %}
        }
        @keyframes spin {
          0% {transform: rotate(0deg);}
      mushroom-state-info$: |
        .primary:after {
          content: 'Ψ§Ω„ΨΉΨ΅Ψ±';
          display: flex;
          flex-direction: column;
          color: skyblue;
        }
        .container {               
          --secondary-text-color: rgba(238,238,228, 0.9);  /* A soft amber for a warm contrast */
          --primary-text-color: orange;
        }
      
    • type: custom:mushroom-template-card
      primary: |
      Maghrib

      Ψ§Ω„Ω…ΨΊΨ±Ψ¨
      secondary: |
      {{ states(β€˜sensor.maghrib_time’) }}
      icon: mdi:mosque-outline
      icon_color: β€œ#00d5ff”
      layout: vertical
      tap_action:
      action: more-info
      entity: sensor.current_prayer
      card_mod:
      style:
      .: |
      ha-card {
      /* Set size and spacing of button */

          {% if states('sensor.current_prayer') == 'Maghrib' %}
            border: 1px outset green; /* Example border color */
            background: rgba(161, 0, 255, 0.5) !important;
          {% else %}
            background: rgba(21,76,121, 0.5) !important; 
          {% endif %}
          
          width: 75px;
          --spacing: 8px;
          padding-bottom: calc(var(--spacing) * 1.718) !important;
          margin-bottom: 5px;
          /* Styling of button */
          
          
          box-shadow: var(--ha-card-box-shadow) !important;
          border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
      
          /* Center button */
          margin-left: auto;
          margin-right: auto;
          transition: all 0s;
        }
      
        /* Add subtle color on hover */
        ha-card:hover {
          background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
          border-color: orange; /* Orange border on hover */
        }
        ha-state-icon {
          {% if states('sensor.current_prayer') == 'Maghrib' %}
            animation: spin 2s linear infinite;
          {% endif %}
        }
        @keyframes spin {
          0% {transform: rotate(0deg);}
      mushroom-state-info$: |
        .primary:after {
          content: 'Ψ§Ω„Ω…ΨΊΨ±Ψ¨';
          display: flex;
          flex-direction: column;
          color: skyblue;
        }
        .container {               
          --secondary-text-color: rgba(238,238,228, 0.9);  /* A soft amber for a warm contrast */
          --primary-text-color: orange;
      
    • type: custom:mushroom-template-card
      primary: Isha
      secondary: |
      {{ states(β€˜sensor.isha_time’) }}
      tap_action:
      action: more-info
      entity: sensor.current_prayer
      icon: mdi:mosque
      icon_color: β€œ#B6ff00”
      layout: vertical
      card_mod:
      style:
      .: |
      ha-card {
      /* Set size and spacing of button */

          {% if states('sensor.current_prayer') == 'Isha' %}
            border: 1px outset green; /* Example border color */
            background: rgba(161, 0, 255, 0.5) !important;
          {% else %}
            background: rgba(21,76,121, 0.5) !important; 
          {% endif %}
          
          width: 75px;
          --spacing: 8px;
          padding-bottom: calc(var(--spacing) * 1.718) !important;
          margin-bottom: 5px;
          /* Styling of button */
          
          
          box-shadow: var(--ha-card-box-shadow) !important;
          border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
      
          /* Center button */
          margin-left: auto;
          margin-right: auto;
          transition: all 0s;
        }
      
        /* Add subtle color on hover */
        ha-card:hover {
          background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
          border-color: orange; /* Orange border on hover */
        }
        ha-state-icon {
          {% if states('sensor.current_prayer') == 'Isha' %}
            animation: spin 2s linear infinite;
          {% endif %}
        }
        @keyframes spin {
          0% {transform: rotate(0deg);}
      mushroom-state-info$: |
        .primary:after {
          content: 'Ψ§Ω„ΨΉΨ΄Ψ§Ψ‘';
          display: flex;
          flex-direction: column;
          color: skyblue;
        }            
        .container {               
          --secondary-text-color: rgba(238,238,228, 0.9);  /* A soft amber for a warm contrast */
          --primary-text-color: orange;
        }
      

card_mod:
style: |
ha-card {
/* Styling of card background */
background: linear-gradient(to bottom right, rgba(95, 158, 160, 0.85, 0.85) 30%, rgba(33,19,13, 0.85) 100%);
}</>
β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™

These are my sensors’
β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™
</> - sensor:
- name: β€œNext Prayer”
state: >
{% set current = now().strftime(β€˜%H:%M’) %}
{% set times = {
β€˜Fajr’: states(β€˜sensor.fajr_time’),
β€˜Dhuhr’: states(β€˜sensor.dhuhr_time’),
β€˜Asr’: states(β€˜sensor.asr_time’),
β€˜Maghrib’: states(β€˜sensor.maghrib_time’),
β€˜Isha’: states(β€˜sensor.isha_time’),
β€˜Sunrise’: states(β€˜sensor.sunrise_time’)
} %}
{% set next = namespace(name=β€˜Isha’, time=times[β€˜Isha’]) %}
{% for name, time in times.items() %}
{% if time and β€˜:’ in time and time > current %}
{% set next.name = name %}
{% set next.time = time %}
{% break %}
{% endif %}
{% endfor %}
{{ next.name }} | {{ next.time }}

  - name: "Time Until Next Prayer"
    state: >
      {% set current = now() %}
      {% set next_prayer = states('sensor.next_prayer').split('|')[1] | trim %}          
      {% if ':' in next_prayer %}
        {% set prayer_hour = next_prayer.split(':')[0] | int %}
        {% set prayer_minute = next_prayer.split(':')[1] | int %}            
        {% set prayer_time = current.replace(
          hour=prayer_hour,
          minute=prayer_minute,
          second=0,
          microsecond=0
        ) %}            
        {% if prayer_time < current %}
          {% set prayer_time = prayer_time + timedelta(days=1) %}
        {% endif %}            
        {% set diff = prayer_time - current %}
        {% set total_minutes = diff.total_seconds() // 60 %}            
        {% set hours = (total_minutes // 60) | int %}
        {% set minutes = (total_minutes % 60) | int %}            
        {% if hours > 0 %}
          {{ hours }}h {{ minutes }}m
        {% else %}
          {{ minutes }}m
        {% endif %}
      {% else %}
        0m
      {% endif %}
      
  - name: "Current Prayer"
    state: >
      {% set current = now().strftime('%H:%M') %}
      {% set prayers = [
        ['Fajr', states('sensor.fajr_time')],
        ['Dhuhr', states('sensor.dhuhr_time')], 
        ['Asr', states('sensor.asr_time')],
        ['Maghrib', states('sensor.maghrib_time')],
        ['Isha', states('sensor.isha_time')]
      ] %}
      
      {# Handle overnight period (after Isha until Fajr) #}
      {% if current >= prayers[-1][1] or current < prayers[0][1] %}
        Isha
      {# Check all prayer periods #}
      {% else %}
        {% set current_prayer = 'Fajr' %} {# Default to Fajr after Fajr time until Dhuhr #}
        {% for i in range(1, prayers|length) %}
          {% if current >= prayers[i][1] %}
            {% set current_prayer = prayers[i][0] %}
          {% endif %}
        {% endfor %}
        {{ current_prayer }}
      {% endif %}
      
  - name: "Prayer Period Debug"
    state: >
      Now: {{ now().strftime('%H:%M') }}
      Current: {{ states('sensor.current_prayer') }}
      Next: {{ states('sensor.next_prayer') }}
      Countdown: {{ states('sensor.time_until_next_prayer') }}
      Schedule:
      Fajr: {{ states('sensor.fajr_time') }}
      Dhuhr: {{ states('sensor.dhuhr_time') }}
      Asr: {{ states('sensor.asr_time') }}
      Maghrib: {{ states('sensor.maghrib_time') }}
      Isha: {{ states('sensor.isha_time') }}
      
  - name: "Active Prayer Countdown"
    state: >
        {% set prayer = states('sensor.next_prayer').split('|')[1] | trim %}
        {% set prayer_hour = prayer.split(':')[0] | int %}
        {% set prayer_minute = prayer.split(':')[1] | int %}
        {% set now = now() %}
        {% set prayer_time = now.replace(hour=prayer_hour, minute=prayer_minute, second=0, microsecond=0) %}
        {% if prayer_time < now %}
          {% set prayer_time = prayer_time + timedelta(days=1) %}
        {% endif %}
        {{ prayer_time.isoformat() }}

  - name: "Next Prayer Timer"
    state: "active"
    attributes:
      friendly_name: "Next Prayer Timer"
      start: "2025-06-23T11:00:00+01:00"
      end: "2025-06-23T18:00:00+01:00"

  - name: "Test Timer"
    state: "active"
    attributes:
      friendly_name: "Test Timer"
      start: "2025-06-23T15:00:00+01:00"
      end: "2025-06-23T16:00:00+01:00"</>

β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™β€˜β€™

My Adhan automation stopped working last week, anyone else having issues? When I go to the automation and click on media it says " Media browsing error

The selected media player is unavailable." Thanks for the help

Post your yaml code for the automation. Maybe someone can assist you fixing it!

@raub21 I was tinkering with it and found out that my sonos speaker is having issues. For some reason it stopped loading in HA. I removed and added the speaker but still no luck with it.

Here is my code for my sonos: `

      - data:
          media_content_id: media-source://media_source/local/asrconverted.mp3
          media_content_type: music
          extra:
            volume: 80
        metadata: {}
        target:
          entity_id: media_player.sonos
        action: media_player.play_media`

I am hosting my own adthan mp3 on home assistant server. You can use that code and replace your adhan mp3 url and sonos player name and test on developers tools<actions

For reference I changed the YAML for the Diyanet approach. Also the API has changed. New code is on my website: Diyanet Ezan in Home Assistant

jazak allah khair for your efforts. One minor thing if you could change the 2 hands together emoji thing. the icons on the card from :pray: which is used by hindos and others to :palms_up_together: . Thank you.