if you are using media player to play mp3 files you can change my shell_command service by the media player, here is an example of service media player:
I am having trouble having the audio play when I trigger all I get is the sound of the Google Home turning on but no audio.
the Alan I am looking to have is the one that I have in the file its a youtube link I do not know how to save it locally or anything like that can someone please help thank you
Automation YAML
Automation for Dhuhr, Asr, Maghrib, and Isha Adhan
#Turning on the input boolean to trigger the Google Homes to start playing the Adhan
service: input_boolean.turn_on
entity_id: input_boolean.adhan #The daly is based on how long the actual Adhan audio is, for this Adhan, it is just around 2 minutes and 14 seconds
delay: ‘00:00:14’
#Seperate automation for the Fajr prayer (~5 AM)
id: ‘151769301092’
alias: Adhan Fajr
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”)) }}’
condition: []
action: #Set the volume of Google Home Speaker to very low, too early for loud audio
#Turn on the input boolean to trigger playing the Adhan on Google Home Speaker
service: input_boolean.turn_on
entity_id: input_boolean.adhan #The daly is based on how long the actual Adhan audio is, for this Adhan, it is just around 2 minutes and 14 seconds
delay: ‘00:5:14’ #After the delay, set the volume back to higher level for Google Home devices
#Below 4 automation simply plays the Adhan on 4 of my speakers at the same time
id: ‘1013101’
alias: Play Adhan Dining Room
trigger:
entity_id: input_boolean.adhan
from: ‘off’
platform: state
to: ‘on’
condition: []
action:
service: media_player.play_media
data:
entity_id: media_player.dining_room_speaker # replace with your Google Home’s id
media_content_id: https://www.youtube.com/watch?v=G96FEkkFCzg # replace with your choice of Adhan
media_content_type: video
You need to use media extractor to play the youtube version of the Athan.
first add media extractor anywhere in your configuration.yaml file like this:
media_extractor:
Next use media extractor to play the audio of that youtube video, here’s my automation.
Just for any passers by. Make sure you have the right timezone in your configuration file. I’m in London and i had utc set as my time zone so this wasnt working as expected.
Hello Aadighal, I’ve been struggling since few days to get the automation , I can manually trigger it and the Adhan plays. Possible to share your config and automation files? any help would be appreciated.
Unfortunately you can’t enter a value template in the Automation editor GUI, to go around that you could create an automation and use a template trigger but leave the value template empty and fill out the rest. Then go to your automation.yaml file and add the value template there. Here’s a picture of the my automation in the Automation editor.
Thank you. I appreciate your offer. Please give us a detailed tutorial. May Allah reward all of you for making our homes filled with the voice of Azaan.
Hi, you can add them to folder and then play all the mp3 files either *.mp3 or you can use Delay: (time for file to end playing) then play the next file and so on, this way you will have a playing order.
This is an example to play random files
- service: shell_command.bienvenida
data_template:
tocar: "/zara/music/saludos/saludos1.mp3"
- delay: '00:01:55' # this is the time it takes to finish playing the saludos1.mp3 file.
- service: shell_command.bienvenida
data_template:
tocar: "/zara/music/saludos/saludos2.mp3"
Shell command:
bienvenida: /usr/bin/mpg123 -a hw:0,0 -q "{{tocar}}"
The “hw:0,0” is the audio hardware if you are using the raspberry and have speakers attached to the raspberry.
i have just rearrange your automation and added delay and “another adhan_duaa.mp3” file as another mp3 file to play.
hope it works.
mjust make sure that the time on the delay its grater than the time your adhan fajir takes by lets say 3 seconds.
what im thinking, not sure if this is correct: value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == 18:30:00, "%H:%M:%S"))}}'
So i created a test block: which doesn’t give me error but doesn’t do much: im assuming the issue is the way i have entered a specific time under value_template…
- alias: TEST BLOCK
id: '1517693010922'
trigger:
- platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")) == as_timestamp("18:15:00", "%H:%M:%S") }}' #so the current time from time_date is 18:10
action:
- service: media_player.volume_set
data:
entity_id: media_player.office_speaker
volume_level: '0.7'
- service: media_extractor.play_media
data:
entity_id: media_player.office_speaker
media_content_id: http://hassio.local:8123/local/adhan_fajr_makkah.mp3
media_content_type: audio/mp3
- delay: '00:03:50' # time it takes to finish playing your adhan_fajr_makkah.mp3
- service: media_extractor.play_media
data:
entity_id: media_player.office_speaker
media_content_id: http://hassio.local:8123/local/dua-e-adhan.mp3
media_content_type: audio/mp3