|
## Official Islamic Prayer Time (extended) ## |
|
## https://www.home-assistant.io/integrations/islamic_prayer_times |
|
sensor: |
|
- platform: template |
|
sensors: |
|
islamic_prayer_times_imsak_time: |
|
friendly_name: "Islamic Prayer Times Imsak time" |
|
device_class: timestamp |
|
icon_template: mdi:calendar-clock |
|
value_template: >- |
|
{% set prayer_times = integration_entities("Islamic Prayer Times") %} |
|
{{ (as_timestamp(states(prayer_times[0])) | int - (10*60)) | timestamp_utc }} |
|
now_prayer: |
|
friendly_name: "Prayer Time" |
|
icon_template: mdi:calendar-clock |
|
value_template: >- |
|
{% set prayer_times = integration_entities("Islamic Prayer Times") %} |
|
{% if now().timestamp() >= as_timestamp(states('sensor.islamic_prayer_times_imsak_time')) and now().timestamp() < as_timestamp(states(prayer_times[0])) %}Imsak |
|
{% elif now().timestamp() >= as_timestamp(states(prayer_times[0])) and now().timestamp() < as_timestamp(states(prayer_times[1])) %}Fajr |
|
{% elif now().timestamp() >= as_timestamp(states(prayer_times[1])) and now().timestamp() < as_timestamp(states(prayer_times[2])) %}Sunrise |
|
{% elif now().timestamp() >= as_timestamp(states(prayer_times[2])) and now().timestamp() < as_timestamp(states(prayer_times[3])) %}Dhuhr |
|
{% elif now().timestamp() >= as_timestamp(states(prayer_times[3])) and now().timestamp() < as_timestamp(states(prayer_times[4])) %}Asr |
|
{% elif now().timestamp() >= as_timestamp(states(prayer_times[4])) and now().timestamp() < as_timestamp(states(prayer_times[5])) %}Maghrib |
|
{% elif now().timestamp() >= as_timestamp(states(prayer_times[5])) and now().timestamp() < as_timestamp(states(prayer_times[6])) %}Isha |
|
{% elif now().timestamp() >= as_timestamp(states(prayer_times[6])) %}Midnight |
|
{% else %}Midnight |
|
{% endif %} |
|
attribute_templates: |
|
timestamp: >- |
|
{% set prayer_times = integration_entities("Islamic Prayer Times") %} |
|
{%if is_state('sensor.now_prayer', 'Imsak') %}{{ states('sensor.islamic_prayer_times_imsak_time') }} |
|
{%elif is_state('sensor.now_prayer', 'Fajr') %}{{ states(prayer_times[0]) }} |
|
{%elif is_state('sensor.now_prayer', 'Sunrise') %}{{ states(prayer_times[1]) }} |
|
{%elif is_state('sensor.now_prayer', 'Dhuhr') %}{{ states(prayer_times[2]) }} |
|
{%elif is_state('sensor.now_prayer', 'Asr') %}{{ states(prayer_times[3]) }} |
|
{%elif is_state('sensor.now_prayer', 'Maghrib') %}{{ states(prayer_times[4]) }} |
|
{%elif is_state('sensor.now_prayer', 'Isha') %}{{ states(prayer_times[5]) }} |
|
{%elif is_state('sensor.now_prayer', 'Midnight') %}{{ states(prayer_times[6]) }} |
|
{%endif%} |
|
12hours: >- |
|
{% set prayer_times = integration_entities("Islamic Prayer Times") %} |
|
{%if is_state('sensor.now_prayer', 'Imsak') %}{{ as_timestamp(states('sensor.islamic_prayer_times_imsak_time')) | timestamp_custom('%I:%M %p') }} |
|
{%elif is_state('sensor.now_prayer', 'Fajr') %}{{ as_timestamp(states(prayer_times[0])) | timestamp_custom('%I:%M %p') }} |
|
{%elif is_state('sensor.now_prayer', 'Sunrise') %}{{ as_timestamp(states(prayer_times[1])) | timestamp_custom('%I:%M %p') }} |
|
{%elif is_state('sensor.now_prayer', 'Dhuhr') %}{{ as_timestamp(states(prayer_times[2])) | timestamp_custom('%I:%M %p') }} |
|
{%elif is_state('sensor.now_prayer', 'Asr') %}{{ as_timestamp(states(prayer_times[3])) | timestamp_custom('%I:%M %p') }} |
|
{%elif is_state('sensor.now_prayer', 'Maghrib') %}{{ as_timestamp(states(prayer_times[4])) | timestamp_custom('%I:%M %p') }} |
|
{%elif is_state('sensor.now_prayer', 'Isha') %}{{ as_timestamp(states(prayer_times[5])) | timestamp_custom('%I:%M %p') }} |
|
{%elif is_state('sensor.now_prayer', 'Midnight') %}{{ as_timestamp(states(prayer_times[6])) | timestamp_custom('%I:%M %p') }} |
|
{%endif%} |
|
24hours: >- |
|
{% set prayer_times = integration_entities("Islamic Prayer Times") %} |
|
{%if is_state('sensor.now_prayer', 'Imsak') %}{{ as_timestamp(states('sensor.islamic_prayer_times_imsak_time')) | timestamp_custom('%H:%M') }} |
|
{%elif is_state('sensor.now_prayer', 'Fajr') %}{{ as_timestamp(states(prayer_times[0])) | timestamp_custom('%H:%M') }} |
|
{%elif is_state('sensor.now_prayer', 'Sunrise') %}{{ as_timestamp(states(prayer_times[1])) | timestamp_custom('%H:%M') }} |
|
{%elif is_state('sensor.now_prayer', 'Dhuhr') %}{{ as_timestamp(states(prayer_times[2])) | timestamp_custom('%H:%M') }} |
|
{%elif is_state('sensor.now_prayer', 'Asr') %}{{ as_timestamp(states(prayer_times[3])) | timestamp_custom('%H:%M') }} |
|
{%elif is_state('sensor.now_prayer', 'Maghrib') %}{{ as_timestamp(states(prayer_times[4])) | timestamp_custom('%H:%M') }} |
|
{%elif is_state('sensor.now_prayer', 'Isha') %}{{ as_timestamp(states(prayer_times[5])) | timestamp_custom('%H:%M') }} |
|
{%elif is_state('sensor.now_prayer', 'Midnight') %}{{ as_timestamp(states(prayer_times[6])) | timestamp_custom('%H:%M') }} |
|
{%endif%} |
|
|
|
automation: |
|
- alias: 🕋 Adzan Automation |
|
description: Play Audio and Notification (Disable this if you wish to use your own) |
|
trigger: |
|
- platform: template |
|
value_template: >- |
|
{{ is_state('sensor.now_prayer', ['Fajr','Dhuhr','Asr','Maghrib','Isha']) |
|
and is_state_attr('sensor.now_prayer', '24hours', now().strftime('%H:%M')) |
|
}} |
|
condition: [] |
|
action: |
|
- service: notify.notify |
|
data: |
|
title: 🕋 Prayer Alert - {{states('sensor.now_prayer')}} |
|
message: >- |
|
{{ now().strftime('%-I:%M %p') }} - It is now |
|
{{states('sensor.now_prayer')}}. Perform your salah. |
|
- service: persistent_notification.create |
|
data: |
|
message: >- |
|
{{ now().strftime('%-I:%M %p') }} - It is now |
|
{{states('sensor.now_prayer')}}. Perform your salah. |
|
title: 🕋 Prayer Alert - {{states('sensor.now_prayer')}} |
|
notification_id: prayertime |
|
- service: media_player.play_media |
|
data: |
|
media_content_type: audio/mp3 |
|
media_content_id: >- |
|
{% if is_state('sensor.now_prayer','Fajr') |
|
%}https://dl.sndup.net/rkrk/azansubuh_alexa.mp3{% else |
|
%}https://dl.sndup.net/c62p/azan_alexa.mp3{% endif %} |
|
extra: |
|
title: Adzan {{states('sensor.now_prayer')}} |
|
thumb: https://i.imgur.com/1U9Ehvr.png |
|
target: |
|
entity_id: media_player.all_devices #Change this to your media player |
|
mode: single |
|
|