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

AoA guys, i have absolutely NO idea about any coding language but i read loads of blogs and was able to setup the azaan to play 5 times on my goolge home perfectly for a couple of months but it suddenly stopped playing a couple of days back. need help and guidance please

@clemalex @123 can one of you experts please review the following and suggest what needs to be changed as the Azan has stopped playing for over a week now.

This is what i currently have in the Automation.yaml file and Configuration.yaml file under File Editor

Automation.yaml

- action:
  - alias: Adhan
    data:
      entity_id: media_player.living_room_speaker
      media_content_id: https://www.youtube.com/watch?v=ADLO-Hm_nCQ
      media_content_type: audio
    service: media_extractor.play_media
  - data:
      entity_id: media_player.living_room_speaker
      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.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"))
      }}'
  id: 0626c5d658d4400588d6ec58a2a32481
- action:
  - alias: Fajr
    data:
      entity_id: media_player.living_room_speaker
      media_content_id: https://www.youtube.com/watch?v=KROnMgEODSA
      media_content_type: audio
    service: media_extractor.play_media
  - data:
      entity_id: media_player.living_room_speaker
      volume_level: '0.5'
    service: media_player.volume_set
  alias: Fajr
  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"))
      }}'
  id: 8ec80238db2a4e4ab9c60dbe20f2c9b3
- alias: Restart HA
  trigger:
    platform: time
    at: 01:00:00
  action:
  - service: homeassistant.restart
  id: 35f993ee217345e797cd48b930cd2411

Configuration.yaml

homeassistant:

  latitude: 43.424773

  longitude: -80.548392

  elevation: -1

  unit_system: metric

  time_zone: America/Toronto

 

sensor:

  - platform: time_date

    display_options:

      - 'time'

      - 'date'

      - 'date_time'

      - 'date_time_iso'

      - 'time_date'

      - 'time_utc'

      - 'beat'

  - platform: islamic_prayer_times

    calculation_method: isna

    sensors:

      - fajr

      - dhuhr

      - asr

      - maghrib

      - isha

media_extractor:

default_config:



tts:

  - platform: google_translate

group: !include groups.yaml

automation: !include automations.yaml

script: !include scripts.yaml

scene: !include scenes.yaml

@tigan If possible can you please review the code that i’ve shared from the Automation.yaml and Configuration.yaml files and recommend changes. Thanks a million

ASAK,

Looking at your code it looks good but i am not an expert by any means. i would recommend looking in your log and seeing if there are any errors at the time your Adhan should have gone off. also go directly to the youtube link and making sure that it is still a good link. if you would want to have a local mp3 of an adhan i can send you mine.

Dan

W Salam,

This is embarrassing but i don’t even know where the log is :stuck_out_tongue:

The youtube link works fine, but can you please share your code for playing the local mp3

Plus i need to figure out how to play azan on multiple speakers at once, any ideas?

nothing to be embarrassed about. in the same place as your config and automation file is there should be something there that has a .log at the end for me it is called home-assistant.log

as for multi speaker setup i use the google homes and set them up in a group that i called home group that i can reference as media_player.home_group

how to play a local file
home-assistant

Have you upgraded Home Assistant recently? Which version are you currently using?

Configuration > Logs

I upgraded the home assistant after it had stopped, hoping that updating would fix the issue but it didnt.

It says Operating System HassOS 4.17
Version 2020.12.6

Go to Configuration > Info and, under System Health, what does it indicate for Version?

This is what the long under configuration looks like

Config entry for ipp not ready yet. Retrying in 5 seconds
11:17:12 AM – config_entries.py (WARNING) - message first occurred at 1:40:44 AM and shows up 420 times

Error fetching ipp data: Invalid response from API: Error occurred while communicating with IPP server.
11:17:12 AM – Internet Printing Protocol (IPP) (ERROR) - message first occurred at 1:40:44 AM and shows up 420 times

Could not retrieve data for the URL: https://www.youtube.com/watch?v=KROnMgEODSA
6:19:03 AM – Media Extractor (ERROR)

ERROR: KROnMgEODSA: YouTube said: Unable to extract video data
6:19:03 AM – Media Extractor (ERROR)

[Living Room TV(192.168.0.28):8009] Heartbeat timeout, resetting connection
4:49:33 AM – /usr/local/lib/python3.8/site-packages/pychromecast/socket_client.py (WARNING) - message first occurred at 3:00:57 AM and shows up 16 times

[Living Room TV(192.168.0.28):8009] Error communicating with socket, resetting connection
4:13:55 AM – /usr/local/lib/python3.8/site-packages/pychromecast/socket_client.py (WARNING) - message first occurred at 4:12:30 AM and shows up 4 times

[Living Room TV(192.168.0.28):8009] Error reading from socket.
4:13:02 AM – /usr/local/lib/python3.8/site-packages/pychromecast/socket_client.py (ERROR)

The islamic_prayer_times platform for the sensor integration does not support platform setup. Please remove it from your config.
1:40:41 AM – Sensor (ERROR)

The version there says 0.118.5

I think the reason it stopped playing is revealed by this message:

Could not retrieve data for the URL: https://www.youtube.com/watch?v=KROnMgEODSA
6:19:03 AM – Media Extractor (ERROR)
ERROR: KROnMgEODSA: YouTube said: Unable to extract video data
6:19:03 AM – Media Extractor (ERROR)

It was unable to access the YouTube video.


You should also follow the instructions provided in this message.

The islamic_prayer_times platform for the sensor integration does not support platform setup. Please remove it from your config.
1:40:41 AM – Sensor (ERROR)

You have this integration configured two ways, via the UI and via configuration.yaml. According to the instructions, you need to remove it from configuration.yaml.

based on that log you need to switch to a local mp3.

i can give you the ones i use if you like.

What is this about?

Yes please!

Is it normal to have loads of errors like i do? or is my setup really messed up? it says some error showed up over 400 times!! :rofl:

you can remove it from your config file and set it up using the intagrations Configurations>Integrations and then do a search for islamic

if it is related to IPP (internet printing protocol) you may need to look at that setup

No.

The log is how Home Assistant reports problems it encounters during its operation. You should inspect it periodically and resolve any errors/warnings.