Assalamo Alaykom brothers,
I would like to share my automation for Athan in Home Assistant.
Pre-requisites:
- Mawaqit Integration installed and set for your location:
(details for installation can be found under this link,go to Settings > Devices & Services > Add Integration and search for "Mawaqit - Media player device in your network
- Athan mp3 sound files ==> example link to download mp3 Athan files
Procedure:
-
install and configure MAWAQIT integration
-
setup up Mawaquit with your nearest mosque:
-
create a folder named salat (or any other name) under
/config/www/
there are several methods to create a folder, in my case I use Studio code server Add on for it, my folder is/config/www/salatand in home assistant code the/config/wwwis replaced by /local/ hence the folder in the code is like this/local/salat/athan.mp3.
Google serach will help you find the best method based on your HA knowledge.
To create a new folder in Home Assistant (HA), use the
File Editor or VS Code add-on to navigate to your/configdirectory and click the “New Folder” icon. Alternatively, use SSH to runmkdir /config/new_folder_name. Common folders to create includewwwfor custom UI files orcustom_components -
download and upload the Athan files to the created folder, in my case it is
/config/www/salat. you would require at least 2 files:
A- Fajr Athan
B- Athan -
get the names of the Athan time sensor entities from Mawaqit integration:
- sensor.fajr_adhan
- sensor.dhuhr_adhan
- sensor.asr_adhan
- sensor.maghrib_adhan
- sensor.isha_adhan
-
create an automation
go to Settings > Automation > + new Automation

-
click on the top right 3 dots and change the edit mode by clicking Edit in YAML
-
paste the bellow code in the automation code window:

- check the names of the prayer time sensor entities and compare them to the names of the sensors in the automation code, make sure replace the sensor names in the five lines entity_id with your own environment sensor entities names:
entity_id: sensor.dhuhr_adhan
- make sure to edit the code to reflect your created Athan folder and Athan file names, it is in this line and repeated for each prayer:
media_content_id: /local/salat/fajr.mp3
- The offset value is set to -3 seconds, please feel free to adjust it based on your environment setup.
offset: “-00:00:03”
My HA requires 3s between launching the automation and executing the Athan command, hence the -3s offset.
AUTOMATION Code:
alias: My 5 Adan calls
description: "Salat times Athan with custom Athan sound files"
triggers:
- trigger: time
at:
entity_id: sensor.fajr_adhan
offset: "-00:00:03"
id: Fajr
- trigger: time
at:
entity_id: sensor.dhuhr_adhan
offset: "-00:00:03"
id: dhuhr
- trigger: time
at:
entity_id: sensor.asr_adhan
offset: "-00:00:03"
id: asr
- trigger: time
at:
entity_id: sensor.maghrib_adhan
offset: "-00:00:03"
id: maghrib
- trigger: time
at:
entity_id: sensor.isha_adhan
offset: "-00:00:03"
id: isha
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- Fajr
sequence:
- action: media_player.play_media
data:
extra:
thumb: /local/salat/athan.png
title: Athan
media:
media_content_id: /local/salat/fajr.mp3
media_content_type: audio/mp3
metadata: {}
target:
entity_id: media_player.ff_kiosk
- conditions:
- condition: trigger
id:
- dhuhr
sequence:
- action: media_player.play_media
data:
extra:
thumb: /local/salat/athan.png
title: Athan
media:
media_content_id: /local/salat/athan.mp3
media_content_type: audio/mp3
metadata: {}
target:
entity_id: media_player.ff_kiosk
- conditions:
- condition: trigger
id:
- asr
sequence:
- action: media_player.play_media
data:
extra:
thumb: /local/salat/athan.png
title: Athan
media:
media_content_id:/local/salat/athan.mp3
media_content_type: audio/mp3
metadata: {}
target:
entity_id: media_player.ff_kiosk
- conditions:
- condition: trigger
id:
- maghrib
sequence:
- action: media_player.play_media
data:
extra:
thumb: /local/salat/athan.png
title: Athan
media:
media_content_id:/local/salat/athan.mp3
media_content_type: audio/mp3
metadata: {}
target:
entity_id: media_player.ff_kiosk
- conditions:
- condition: trigger
id:
- isha
sequence:
- action: media_player.play_media
data:
extra:
thumb: /local/salat/athan.png
title: Athan
media:
media_content_id: /local/salat/athan.mp3
media_content_type: audio/mp3
metadata: {}
target:
entity_id: media_player.ff_kiosk
mode: single
-
if you like the media player to show a Athan picture, download one and save it in the same folder as the Athan files, in my case it is
/local/salat/athan.png -
save the automation and test it
-
you can switch to visual mode to modify the automation.
You can also setup different Athans for each prayer by specifying another Athan mp3 file.
I hope this helps you.
Assalamo Alaykom

