-
-
Save AalianKhan/322c6ed840cecc5fc5043281d7224674 to your computer and use it in GitHub Desktop.
# MIT License | |
# | |
# Copyright (c) 2024 Aalian Khan | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all | |
# copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
blueprint: | |
name: "🔊 Adhan Announcement" | |
description: Play the adhan on selected speakers while also pausing media players | |
of your choice. You can also add islamic month sensor to play suhoor and iftar | |
dua. You can also optionally disable Fajr adhan. | |
Make sure you the sensors that stores the timestamp for the adhan are named as following | |
sensor.fajr_prayer | |
sensor.dhuhr_prayer | |
sensor.asr_prayer | |
sensor.maghrib_prayer | |
sensor.isha_prayer | |
domain: automation | |
input: | |
play_media_player: | |
name: Media players to play | |
description: The Media players to play the Adhan on | |
selector: | |
target: | |
entity: | |
domain: media_player | |
wait_media_player: | |
name: Media player to wait for | |
description: The media player to wait for and check if adhan is finished and | |
continue the automation. Pick any 1 media player you selected above. | |
selector: | |
entity: | |
domain: media_player | |
multiple: false | |
fajr: | |
name: Play on fajr? | |
description: Should it play the adhan for fajr? | |
default: {} | |
selector: | |
boolean: {} | |
pause_media_player: | |
name: Media players to pause (Optional) | |
description: The Media players to pause when the Adhan plays. Such as TVs | |
default: {} | |
selector: | |
target: | |
entity: | |
domain: media_player | |
resume_media: | |
name: Resume paused media players after adhan? | |
description: Should it resume all paused media players after the adhan has played? | |
default: false | |
selector: | |
boolean: {} | |
change_volume: | |
name: Change the volume? | |
description: Should it adjust the volume when playing the adhan? | |
default: false | |
selector: | |
boolean: {} | |
volume: | |
name: The volume to set to (Optional) | |
description: The volume to set to while the adhan is playing | |
default: 0.25 | |
selector: | |
number: | |
min: 0 | |
max: 1 | |
step: 0.05 | |
islamic_month_sensor: | |
name: Islamic month sensor (Optional) | |
description: The sensor to check what month it is in the islamic calendar. An entity_id is required, put sun.sun you don't want to use it | |
default: "sun.sun" | |
selector: | |
entity: {} | |
islamic_month_sensor_value: | |
name: Islamic month sensor value (Optional) | |
description: The value to check from the sensor to see if it is Ramadan | |
default: "" | |
selector: | |
text: {} | |
fajr_mp3: | |
name: Path to Fajr adhan MP3 (Optional) | |
description: Enter the path where your custom media player is stored. Examples, | |
media-source://media_source/local/fajr_adhan.mp3 (local path is /media/fajr_adhan.mp3), | |
or an address such as https://www.islamcan.com/audio/adhan/azan1.mp3. Defaults | |
to my Github | |
default: https://github.com/AalianKhan/adhans/blob/master/adhan_fajr.mp3?raw=true | |
selector: | |
text: {} | |
adhan_mp3: | |
name: Path to adhan MP3 (Optional) | |
description: Enter the path where your custom media player is stored. Examples, | |
media-source://media_source/local/adhan.mp3 (local path is /media/adhan.mp3), | |
or an address such as https://www.islamcan.com/audio/adhan/azan1.mp3. Defaults | |
to my Github | |
default: https://github.com/AalianKhan/adhans/blob/master/adhan.mp3?raw=true | |
selector: | |
text: {} | |
suhoor_mp3: | |
name: Path to Suhoor dua MP3 (Optional) | |
description: Enter the path where your custom media player is stored. Examples, | |
media-source://media_source/local/suhoor_dua.mp3 (local path is /media/suhoor_dua.mp3), | |
or an address such as https://www.islamcan.com/audio/adhan/azan1.mp3. Defaults | |
to my Github | |
default: https://github.com/AalianKhan/adhans/blob/master/suhoor_dua.mp3?raw=true | |
selector: | |
text: {} | |
iftaar_mp3: | |
name: Path to Iftaar dua MP3 (Optional) | |
description: Enter the path where your custom media is stored. Examples, media-source://media_source/local/iftaar_dua.mp3 | |
(local path is /media/ftaar_dua.mp3), or an address such as https://www.islamcan.com/audio/adhan/azan1.mp3. | |
Defaults to my Github | |
default: https://github.com/AalianKhan/adhans/blob/master/iftar_dua.mp3?raw=true | |
selector: | |
text: {} | |
source_url: https://gist.github.com/AalianKhan/322c6ed840cecc5fc5043281d7224674 | |
variables: | |
wait_media_player: !input wait_media_player | |
play_fajr: !input fajr | |
media_resume: !input resume_media | |
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: !input islamic_month_sensor | |
state: !input islamic_month_sensor_value | |
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: !input pause_media_player | |
data: {} | |
- service: media_player.play_media | |
target: !input play_media_player | |
data: | |
media_content_id: !input suhoor_mp3 | |
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: !input play_media_player | |
data: | |
media_content_id: !input fajr_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: !input pause_media_player | |
data: {} | |
- conditions: | |
- condition: trigger | |
id: maghrib_trigger | |
sequence: | |
- service: media_player.media_pause | |
target: !input pause_media_player | |
data: {} | |
- service: media_player.play_media | |
target: !input play_media_player | |
data: | |
media_content_id: !input iftaar_mp3 | |
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: !input play_media_player | |
data: | |
media_content_id: !input adhan_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: !input pause_media_player | |
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: !input pause_media_player | |
data: {} | |
- service: media_player.play_media | |
target: !input play_media_player | |
data: | |
media_content_id: !input adhan_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 | |
- if: | |
- condition: template | |
value_template: '{{ media_resume }}' | |
then: | |
- service: media_player.media_play | |
target: !input pause_media_player | |
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: !input pause_media_player | |
data: {} | |
- service: media_player.play_media | |
target: !input play_media_player | |
data: | |
media_content_id: !input fajr_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: !input pause_media_player | |
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: !input pause_media_player | |
data: {} | |
- service: media_player.play_media | |
target: !input play_media_player | |
data: | |
media_content_id: !input adhan_mp3 | |
media_content_type: mp3 | |
# - service: scene.create | |
# data: | |
# snapshot_entities: !input play_media_player | |
# scene_id: before_adhan | |
# - if: | |
# - condition: template | |
# value_template: '{{ change_volume }}' | |
# then: | |
# - service: media_player.volume_set | |
# data: | |
# volume_level: !input volume | |
# target: !input play_media_player | |
- delay: | |
hours: 0 | |
minutes: 0 | |
seconds: 2 | |
milliseconds: 0 | |
- wait_template: '{{ is_state(wait_media_player, ''idle'') }}' | |
timeout: 00:05:00 | |
# - service: scene.turn_on | |
# data: {} | |
# target: | |
# entity_id: scene.before_adhan | |
# enabled: true | |
- if: | |
- condition: template | |
value_template: '{{ media_resume }}' | |
then: | |
- service: media_player.media_play | |
target: !input pause_media_player | |
data: {} |
Hi @oerix you can configure this new sensor in your home assistant configuration.yaml
https://www.home-assistant.io/integrations/rest
For example, I have this config
sensor:
- platform: rest
name: Islamic Month
resource_template: http://api.aladhan.com/v1/gToH/?date={{ now().strftime("%d-%m-%Y") }}&adjustment=1
value_template: "{{ value_json.data.hijri.month.en }}"
Then you can reference this sensor in automation and in the value you can write "Ramadan"
Jazak'Allah Khaiyran for this. However, that option field is labelled as 'optional', and it looks like the developer is ignoring all requests to fix this prolonged bug.
Salam @oerix,
I'm sorry for not getting back to you sooner. The truth is I wasn't totally sure how to fix it and left it at that (totally my mistake). It turns out I was just overthinking it. Basically, it needs some entity_ID to look at for it to save. So I gave it just that, I believe every installation has a sun.sun so I have set that as the default entity_ID. Before I was trying to find a way to not look for an entity_ID but I couldn't find one so this is the next best solution.
Again sorry for the very very late response.
Can you address this issue please? It's been nearly a year now @AalianKhan