Adhan Automation (الأذان التلقائي للصلاة) using google speaker

Thanks for the response @chintito4ever. Yes both the nest mini and Audio connected to the same wifi as HA.However it is still unfindable. I have a new Nest Audio and Nest Mini which are not findable as an Entity or as a Devices.

I do have a Sonos Beam speaker and Google Chromecast. Those are findable as entities without any issues. I am missing anything here?

Hi @msahar and brothers,
I am having the same configuration and automation content but it is not triggering the azan automatically. Manually, I can able to trigger and it plays without issue.

Code of configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
# to find lat and long - https://www.maps.ie/coordinates.html
homeassistant:
  latitude: 43.75167
  longitude: -79.26541
  unit_system: metric
  time_zone: America/Toronto
  external_url: "secrect!"
  media_dirs:
    media: "/media"

default_config:
discovery:
media_extractor:
sun:

# Islamic prayer times integration starts updated 12/04/22
# Sensors
sensor:
  - platform: time_date
    display_options:
      - "time"
      - "date"
      - "date_time"
      - "time_date"
  - platform: islamic_prayer_times
    calculation_method: isna
    sensors:
      - fajr
      - dhuhr
      - asr
      - maghrib
      - isha

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
# Test

Code for automation.yaml

# Automation for Fajr times Adhan(consists of 3 parts theaction, thealias and thetrigger)

- action:
    - alias: "FajrAdhan"
      data:
        entity_id: media_player.nestmini8653
        media_content_id: http://myip:8123/local/adhan/fajr-adhan-mansoor.mp3
        media_content_type: audio/mp3
      service: media_extractor.play_media
    - data:
        entity_id: media_player.nestmini8653
        volume_level: "0.6"
      service: media_player.volume_set
  alias: Fajr_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_time_fajr"), "%Y-%m-%dT%H:%M:%S")) }}'

# Automation for 4 times Azan
- action:
    - alias: "FourAdhan"
      data:
        entity_id: media_player.nestmini8653
        media_content_id: http://myip:8123/local/adhan/all-adhan-mishary.mp3
        media_content_type: audio/mp3
      service: media_extractor.play_media
    - data:
        entity_id: media_player.nestmini8653
        volume_level: "0.8"
      service: media_player.volume_set
  alias: Four_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_time_dhuhr"), "%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_time_asr"), "%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_time_maghrib"), "%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_time_isha"), "%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

Attaching the states screenshots. The sensor for dhuhr is mentioned as ‘2022-12-05T17:08:00+00:00’. I am sure this is not the correct time for dhuhr in North America (Toronto). Similarly for all the other prayers. Is that anything configured incorrectly? Please help.

HAAthanStates-3



If you go to Settings>Automation>Your Adhan Automation>Traces it should show the logs why it failed. Can you see what your traces show?

Thanks for the response @chintito4ever. I am not anything when clicked the trace. Is that any other place i need to look at?

I am able to enable the tracing after restart of HA instance. Now by manually triggering the automation for Fajr and All four Adan, Trace is available. PFB.

However, I am still seeing the sensor times are incorrect for the Toronto, Canada location. Do you see any issues below?

Dear brothers,
The automation is working for me now. I have updated my automations.yaml file as follows.

# Automation for 4 times Azan
- action:
    - alias: "FourAdhan"
      data:
        entity_id: media_player.nestmini8653
        media_content_id: http://local:8123/local/adhan/all-adhan-mishary.mp3
        media_content_type: audio/mp3
      service: media_extractor.play_media
    - data:
        entity_id: media_player.nestmini8653
        volume_level: "0.8"
      service: media_player.volume_set
  alias: Four_Adhan
  condition: []
  id: "1517694139312"
  trigger:
    - platform: template
      value_template: '{{ now().timestamp()|int == as_timestamp(states("sensor.dhuhr_prayer")) }}'
    - platform: template
      value_template: '{{ now().timestamp()|int == as_timestamp(states("sensor.asr_prayer")) }}'
    - platform: template
      value_template: '{{ now().timestamp()|int == as_timestamp(states("sensor.maghrib_prayer")) }}'
    - platform: template
      value_template: '{{ now().timestamp()|int == as_timestamp(states("sensor.isha_prayer")) }}'

Based on the logs and suggestion from following threads, I am able to resolve it. Islamic Prayer Times issue with the sensor integration after Core update - does not support platform setup · Issue #73201 · home-assistant/core · GitHub
Offset time - #37 by om3r

Salaam Brothers,

I have the automation working perfectly minus one small thing. The Islamic Prayer Time integration doesn’t have a calculation for the UK, the closest is MWL but it isn’t correct. Is there a way I can correct this without having to change anything constantly.

Thanks

Salaam everyone,

can someone help me do azan automation but play via alexa

prayer time: London

Thanks

@Nameless900 , you may want to check this post

It’s been described here

Can you help me with configuration and automation with diyanet Netherlands files?

Can you please put more clarification about what you need?

are you using my addo? if yes there is a description how to configure that

I’ve been trying to get your addon to work but I’m getting unknown when I remove == states(‘sensor.time’) and always false if I dont.

If I run http://localhost:1453/api/dailyPrayerTimes/11421 I get correct results

{"regionId":11421,"region":"Melbourne","prayerTimes":[{"date":"23.03.2023","fajr":"05:58","sun":"07:18","dhuhur":"13:32","asr":"16:56","maghrib":"19:36","isha":"20:51"},{"date":"24.03.2023","fajr":"05:59","sun":"07:19","dhuhur":"13:32","asr":"16:55","maghrib":"19:34","isha":"20:49"}]}

This is what I have added in my configuration.yaml

  - platform: rest
    name: namaz_vakti
    resource: "http://localhost:1453/api/dailyPrayerTimes/11421"
    scan_interval: 25200
    json_attributes_path: $.prayerTimes[0]
    json_attributes:
      - date
      - fajr
      - sun
      - dhuhur
      - asr
      - maghrib
      - isha
    value_template: >
      {% set now = now() %}
      {% set fajr = today_at(state_attr('sensor.namaz_vakti', 'fajr')) %}
      {% set sun = today_at(state_attr('sensor.namaz_vakti', 'sun')) %}
      {% set dhuhur = today_at(state_attr('sensor.namaz_vakti', 'dhuhur')) %}
      {% set asr = today_at(state_attr('sensor.namaz_vakti', 'asr')) %}
      {% set maghrib = today_at(state_attr('sensor.namaz_vakti', 'maghrib')) %}
      {% set isha = today_at(state_attr('sensor.namaz_vakti', 'isha')) %}
      {% if now < fajr %}
        Imsak: {{ state_attr('sensor.namaz_vakti', 'fajr') }}
      {% elif now < sun %}
        Gunes: {{ state_attr('sensor.namaz_vakti', 'sun') }}
      {% elif now < dhuhur %}
        Oglen: {{ state_attr('sensor.namaz_vakti', 'dhuhur') }}
      {% elif now < asr %}
        Ikindi: {{ state_attr('sensor.namaz_vakti', 'asr') }}
      {% elif now < maghrib %}
        Aksam: {{ state_attr('sensor.namaz_vakti', 'maghrib') }}
      {% elif now < isha %}
        Yatsi: {{ state_attr('sensor.namaz_vakti', 'isha') }}
      {% else %}
        unknown
      {% endif %}
      
  - platform: template
    sensors:
      diyanet_imsak_vakti:
        friendly_name: "Imsak Vakti"
        value_template: "{{state_attr('sensor.namaz_vakti', 'fajr') }}"
      diyanet_gunes_vakti:
        friendly_name: "Gunes Vakti"
        value_template: "{{state_attr('sensor.namaz_vakti', 'sun') }}"
      diyanet_ogle_namazi:
        friendly_name: "Ogle Vakti"
        value_template: "{{state_attr('sensor.namaz_vakti', 'dhuhur') }}"
      diyanet_ikindi_namazi:
        friendly_name: "Ikindi Vakti"
        value_template: "{{state_attr('sensor.namaz_vakti', 'asr') }}"
      diyanet_aksam_namazi:
        friendly_name: "Aksam Vakti"
        value_template: "{{state_attr('sensor.namaz_vakti', 'maghrib') }}"
      diyanet_yatsi_namazi:
        friendly_name: "Yatsi Vakti"
        value_template: "{{state_attr('sensor.namaz_vakti', 'isha') }}"

  - platform: template
    sensors:
      imsak_notify:
        friendly_name: "İmsak Vakti Notify"
        value_template: "{{state_attr('sensor.namaz_vakti', 'fajr') == states('sensor.time')}}"
      gunes_notify:
        friendly_name: "Güneş Vakti Notify"
        value_template: "{{state_attr('sensor.namaz_vakti', 'sun') == states('sensor.time')}}"
      ogle_notify:
        friendly_name: "Öğle Vakti Notify"
        value_template: "{{state_attr('sensor.namaz_vakti', 'dhuhur') == states('sensor.time')}}"
      ikindi_notify:
        friendly_name: "İkindi Vakti Notify"
        value_template: "{{state_attr('sensor.namaz_vakti', 'asr') == states('sensor.time')}}"
      aksam_notify:
        friendly_name: "Akşam Vakti Notify"
        value_template: "{{state_attr('sensor.namaz_vakti', 'maghrib') == states('sensor.time')}}"
      yatsi_notify:
        friendly_name: "Yatsı Vakti Notify"
        value_template: "{{state_attr('sensor.namaz_vakti', 'isha') == states('sensor.time')}}"

Hi Sahar,

I have been to setup the Adan integrations for a few days with little success, I can trigger adan manually if I run the script but the automation piece does not work - below are my config and automation files, if you coud kindly assist please -

Config File -
/
homeassistant:
latitude: 43.526646
longitude: -79.891205
elevation: 217
unit_system: metric
time_zone: America/Toronto

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.fajr_prayer”).split(“T”)[1].split(":")[0] -%}
    {%- set b = states(“sensor.fajr_prayer”).split(“T”)[1].split(":")[1] -%}
    {{ a + “:” + b }}
    salah_dhuhr:
    friendly_name: “Salah Dhuhr”
    value_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 }}
    salah_asr:
    friendly_name: “Salah Asr”
    value_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 }}
    salah_maghrib:
    friendly_name: “Salah Maghrib”
    value_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 }}
    salah_isha:
    friendly_name: “Salah Isha”
    value_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 }}
    automation: !include automations.yaml
    script: !include scripts.yaml
    scene: !include scenes.yaml
    /

my Automation File -

/
id: ‘1679835844405’
alias: Adhan
description: ‘’
trigger:

  • platform: template
    value_template: ‘{{ as_timestamp(strptime(states(“sensor.time_date”), “%H:%M,
    %Y-%m-%d”)) == as_timestamp(strptime(states(“sensor.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.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.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.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.isha_prayer”), “%Y-%m-%dT%H:%M:%S”))
    }}’
    condition: []
    action:
  • alias: Azan
    data:
    entity_id: media_player.all_g_display
    media_content_id: http://192.168.86.68:8123/local/AthanByYusufIslam.mp3
    media_content_type: audio/mp3
    service: media_extractor.play_media
  • data:
    entity_id: media_player.all_g_display
    volume_level: ‘0.6’
    service: media_player.volume_set
    mode: single
  • alias: Restart HA
    trigger:
    platform: time
    at: 01:00:00
    action:
    • service: homeassistant.restart
      id: 6145b39c17954cc0a47b4e22e51193cb
  • id: ‘1679837642811’
    alias: Restart HA
    description: ‘’
    trigger:
    • platform: time
      at: 01:00:00
      condition: []
      action:
    • service: homeassistant.restart
      data: {}
      mode: single
      /sensors
      I live in Milton, Ontario , Canada - please see attachd picture for sensor status it shows unavailable all across.

I got this automation but its not triggering:

  • id: ‘1676133222550’
    alias: 1 Ezan Sabah
    trigger:
    • platform: state
      entity_id:
      • sensor.namaz_vakti
        to: ‘True’
        attribute: asr
        condition: []
        action:
    • service: media_player.play_media
      data:
      media_content_id: media-source://media_source/local/Azan.mp3
      media_content_type: audio/mp3
      target:
      entity_id: media_player.keuken_display
    • service: media_player.volume_set
      data:
      volume_level: 0.4
      target:
      entity_id: media_player.keuken_display
      mode: single

hi may i know where can i get the “ID” from?

The value of the automation’s id option can be whatever you want, as long as it’s different from any other automation.

Did you have found any solution? I am looking a solution to see on an separate sensor the next Prayer TIme.

i have now problem with fetching data and i think something breaks now with REST api. The sensors says unknown now. By me nothing was changed. What can be the problem?