🔊 Ready to go blueprint for playing adhan / azan on media players with many optional features

Hi,

So, Asr didn’t play when the radio was not playing on the speaker.
when it worked for Dohr, the radio was playing. My non expert explanation is I reckon there are 2 possible reasons:

  1. the player was “duplicated” yesterday when I installed Music Assistant to listen to web radio, then I added this duplicated player in the list of media players for Athan. It could be that this “second” duplicated player was recognised
    or 2. I noticed that the player (and its music assistant duplicate), in the main dashboard is showing as off (grey), but maybe it should be showing in blue (on). When I push the on button, I hear a chime on the player (google assistant). I will leave it on, without playing anything on it, but I think it automatically goes off, and it will definitely go off next time something stops playing. I thought the automation would turn it on anyway.

In any case thanks for the help. I think for this one I don’t have the skills to sort it, so if it doesn’t work that will be it unfortunately.

I’m attaching the set-up screen. note that the 2 players are the same, but one seems created by music assistant.

ASAK AlianKhan

I have been using this for a couple year now. It’s been working great. Recently I moved to a new place. I only have one smart speaker and no other device to add under media to pause (which aparantly is mandatory).

Are you able to help me with a template which does not require media player to wait for? Or is there a way I can edit to remove this logic?

Appreciate your help.

W salam,
You can just select the same media player for the media player to pause.
Let me know if that works for you

Thanks brother. I made those changes. Now I notice this is not getting triggered. I see the Islamic Prayer Times sensors are working and correct prayer times are displayed on the dashboard. When I checked the traces for the Adhan integration, I don’t see any activities.

hmm, is the automation enabled? can you also share configuration and if possible any traces

Yes, it is enabled:

alias: :loud_sound: Adhan Announcement
description: “”
use_blueprint:
path: AalianKhan/Adhan.yaml
input:
play_media_player:
entity_id: media_player.googlehome3229
wait_media_player: media_player.googlehome3229
islamic_month_sensor: sensor.islamic_month
islamic_month_sensor_value: Ramadan
resume_media: false
fajr: true
fajr_mp3: htt ps:// media.sd.ma/assabile/adhan_3435370/ddb21f7363eb.mp3
change_volume: false
volume: 1

Configuration:

variables:
wait_media_player: media_player.googlehome3229
play_fajr: true
media_resume: false
trigger:

  • platform: time
    at: sensor.fajr_prayer
    id: fajr_trigger
  • platform: time
    at: sensor.dhuhr_prayer
    id: dhuhr_trigger
  • platform: time
    at: sensor.asr_prayer
    id: asr_trigger
  • platform: time
    at: sensor.maghrib_prayer
    id: maghrib_trigger
  • platform: time
    at: sensor.isha_prayer
    id: isha_trigger
    action:
  • choose:
    • conditions:
      • condition: state
        entity_id: sensor.islamic_month
        state: Ramadan
        sequence:
      • choose:
        • conditions:
          • condition: and
            conditions:
            • condition: trigger
              id: fajr_trigger
            • condition: template
              value_template: ‘{{ play_fajr == true }}’
              sequence:
          • service: media_player.media_pause
            target: {}
            data: {}
          • service: media_player.play_media
            target:
            entity_id: media_player.googlehome3229
            data:
            media_content_id: >-
            htt ps://github.com/ AalianKhan/adhans/blob/master/suhoor_dua.mp3?raw=true
            media_content_type: mp3
          • delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
          • wait_template: ‘{{ is_state(wait_media_player, ‘‘idle’’) }}’
            timeout: ‘00:05:00’
          • service: media_player.play_media
            target:
            entity_id: media_player.googlehome3229
            data:
            media_content_id: >-
            ht tps://media.sd.ma/ assabile/adhan_3435370/ddb21f7363eb.mp3
            media_content_type: mp3
          • condition: template
            value_template: ‘{{ media_resume }}’
          • delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
          • wait_template: ‘{{ is_state(wait_media_player, ‘‘idle’’) }}’
            timeout: ‘00:05:00’
          • service: media_player.media_play
            target: {}
            data: {}
        • conditions:
          • condition: trigger
            id: maghrib_trigger
            sequence:
          • service: media_player.media_pause
            target: {}
            data: {}
          • service: media_player.play_media
            target:
            entity_id: media_player.googlehome3229
            data:
            media_content_id: >-
            ht tps://github.com/ AalianKhan/adhans/blob/master/iftar_dua.mp3?raw=true
            media_content_type: mp3
          • delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
          • wait_template: ‘{{ is_state(wait_media_player, ‘‘idle’’) }}’
            timeout: ‘00:05:00’
          • service: media_player.play_media
            target:
            entity_id: media_player.googlehome3229
            data:
            media_content_id: >-
            ht tps://github.com/AalianKhan/adhans/blob/master/adhan.mp3?raw=true
            media_content_type: mp3
          • condition: template
            value_template: ‘{{ media_resume }}’
          • delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
          • wait_template: ‘{{ is_state(wait_media_player, ‘‘idle’’) }}’
            timeout: ‘00:05:00’
          • service: media_player.media_play
            target: {}
            data: {}
        • conditions:
          • condition: or
            conditions:
            • condition: trigger
              id: dhuhr_trigger
            • condition: trigger
              id: asr_trigger
            • condition: trigger
              id: isha_trigger
              sequence:
          • service: media_player.media_pause
            target: {}
            data: {}
          • service: media_player.play_media
            target:
            entity_id: media_player.googlehome3229
            data:
            media_content_id: >-
            htt ps://github.com/ AalianKhan/adhans/blob/master/adhan.mp3?raw=true
            media_content_type: mp3
          • condition: template
            value_template: ‘{{ media_resume }}’
          • delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
          • wait_template: ‘{{ is_state(wait_media_player, ‘‘idle’’) }}’
            timeout: ‘00:05:00’
          • if:
            • condition: template
              value_template: ‘{{ media_resume }}’
              then:
            • service: media_player.media_play
              target: {}
              data: {}
              default:
    • choose:
      • conditions:
        • condition: and
          conditions:
          • condition: trigger
            id: fajr_trigger
          • condition: template
            value_template: ‘{{ play_fajr == true }}’
            sequence:
        • service: media_player.media_pause
          target: {}
          data: {}
        • service: media_player.play_media
          target:
          entity_id: media_player.googlehome3229
          data:
          media_content_id: ht tps://media.sd.ma/ assabile/adhan_3435370/ddb21f7363eb.mp3
          media_content_type: mp3
        • condition: template
          value_template: ‘{{ media_resume }}’
        • delay:
          hours: 0
          minutes: 0
          seconds: 2
          milliseconds: 0
        • wait_template: ‘{{ is_state(wait_media_player, ‘‘idle’’) }}’
          timeout: ‘00:05:00’
        • service: media_player.media_play
          target: {}
          data: {}
      • conditions:
        • condition: or
          conditions:
          • condition: trigger
            id: dhuhr_trigger
          • condition: trigger
            id: asr_trigger
          • condition: trigger
            id: maghrib_trigger
          • condition: trigger
            id: isha_trigger
            sequence:
        • service: media_player.media_pause
          target: {}
          data: {}
        • service: media_player.play_media
          target:
          entity_id: media_player.googlehome3229
          data:
          media_content_id: >-
          htt ps://github.com/ AalianKhan/adhans/blob/master/adhan.mp3?raw=true
          media_content_type: mp3
        • delay:
          hours: 0
          minutes: 0
          seconds: 2
          milliseconds: 0
        • wait_template: ‘{{ is_state(wait_media_player, ‘‘idle’’) }}’
          timeout: ‘00:05:00’
        • if:
          • condition: template
            value_template: ‘{{ media_resume }}’
            then:
          • service: media_player.media_play
            target: {}
            data: {}
            id: ‘1710272080884’
            alias: :loud_sound: Adhan Announcement
            description: ‘’

Appreciate your help.

can you check the entity_id of the sensors and check if it is same? if its not, manually edit the name to the proper ones.

I see for Asr it is sensor.islamic_prayer_times_asr_prayer

Where can I update these?


Can I update here?

yup, edit that to look like sensor.asr_prayer. all the proper names are listed in the description of the blueprint.


Why?

its failing because it is unable pause the media player. probably because its empty even though it should still ignore the error and continue forward. I will take a look and update you. if you can, can you try selecting a media player to pause.

I have updated the blueprint and works as expected with my setup. Please reimport the blueprint and let me know how it goes.

Thanks for looking into this. It started working again yesterday.

I did notice that sometimes the speaker chimes but the Adhan doesn’t play. I assume this might be due to buffering or network congestion when multiple devices are trying to access the MP3 file from GitHub.

Would you recommend using an alternative source for the Adhan MP3?

Interesting, so the blueprints do auto update after all :smile:.

I personally didn’t have that issue (yet). Do the speakers have status buffering but never play? You can check that in the logbook. You can try another source and see if it fixes it. Since I don’t have that issue, I can’t really troubleshoot it but maybe with some more info I can look into it.

I finally got this issue, I managed to fix it by just downloading the mp3 and uploading to my home assistant media folder. I then replaced the URL to point to the media file media-source://media_source/local/adhan.mp3.

1 Like

Yes, I replaced the url from your github mp3s to another one on internet. Looks like github is throttling due to too many concurrent users.

1 Like