@joohann Thanks very much for this thread! Do you mind sharing the UI cards or setup, how to have the same setup? Thanks very much!
I Forgot, I use chim tts!
configuration.yaml
sensor:
- platform: template
sensors:
is_ramadan:
friendly_name: "Is it Ramadan?"
value_template: >-
{% if 'Ramaḍān' in states('sensor.hijri_month') %}
true
{% else %}
false
{% endif %}
icon_template: mdi:skip-next-circle
- platform: template
sensors:
hijri_calendar:
friendly_name: "{{states('sensor.hijri_year')}}"
value_template: >
{{states('sensor.hijri_day')}} - {{states('sensor.hijri_month')}}
icon_template: mdi:star-crescent
next_prayer:
friendly_name: "Next Prayer"
value_template: >
{% set s_list = {'sensor.fajr': 'Fajr', 'sensor.dhuhr': 'Dhuhr', 'sensor.asr': 'Asr', 'sensor.maghrib': 'Maghrib', 'sensor.isha': 'Isha'} %}
{% set local_time = now().timestamp() %}
{% set upcoming_events = expand(s_list.keys() | select('has_value'))
| selectattr('state', 'ge', (local_time)|timestamp_custom('%Y-%m-%dT%H:%M:%S', False))
| list %}
{% if upcoming_events %}
{% set first = upcoming_events | sort(attribute='state') | first %}
{% set time_difference = (as_timestamp(first.state) - local_time) / 60 %}
{% if time_difference < 60 %}
{{ s_list[first.entity_id] }} in {{ time_difference | round(0) }} minutes
{% elif time_difference_minutes == 1 %}
1 minute
{% else %}
{{ as_timestamp(first.state) | timestamp_custom('%H:%M') }} ({{ s_list[first.entity_id] }})
{% endif %}
{% else %}
No upcoming prayer
{% endif %}
icon_template: mdi:skip-next-circle
rest:
- resource: http://api.aladhan.com/timingsByCity?city=yourcity&country=Netherlands&method=3
scan_interval: 43200
sensor:
- name: "Imsak"
unique_id: imsak
value_template: >
{% set time_str = value_json['data']['timings']['Imsak'] %}
{% set date_time_str = now().date().isoformat() + ' ' + time_str %}
{% set amsterdam_tz = 'Europe/Amsterdam' %}
{% set amsterdam_time = as_timestamp(strptime(date_time_str, '%Y-%m-%d %H:%M')) | timestamp_custom('%Y-%m-%dT%H:%M:%S+02:00', amsterdam_tz) %}
{{ amsterdam_time }}
device_class: timestamp
icon: mdi:mosque
- name: "Imsak_readable"
unique_id: imsak_readable
value_template: "{{ as_timestamp(today_at(value_json['data']['timings']['Imsak'])) | timestamp_custom('%H:%M') }}"
icon: mdi:mosque
- name: "Fajr"
unique_id: fajr
value_template: >
{% set time_str = value_json['data']['timings']['Fajr'] %}
{% set date_time_str = now().date().isoformat() + ' ' + time_str %}
{% set amsterdam_tz = 'Europe/Amsterdam' %}
{% set amsterdam_time = as_timestamp(strptime(date_time_str, '%Y-%m-%d %H:%M')) | timestamp_custom('%Y-%m-%dT%H:%M:%S+01:00', amsterdam_tz) %}
{{ amsterdam_time }}
device_class: timestamp
icon: mdi:mosque
- name: "Fajr Readable"
unique_id: fajr_readable
value_template: "{{ as_timestamp(today_at(value_json['data']['timings']['Fajr'])) | timestamp_custom('%H:%M') }}"
icon: mdi:mosque
- name: "Dhuhr"
unique_id: dhuhr
value_template: >
{% set time_str = value_json['data']['timings']['Dhuhr'] %}
{% set date_time_str = now().date().isoformat() + ' ' + time_str %}
{% set amsterdam_time = as_timestamp(strptime(date_time_str, '%Y-%m-%d %H:%M')) | timestamp_custom('%Y-%m-%dT%H:%M:%S+01:00', 'Europe/Amsterdam') %}
{{ amsterdam_time }}
device_class: timestamp
icon: mdi:mosque
- name: "Dhuhr Readable"
unique_id: dhuhr_readable
value_template: "{{ as_timestamp(today_at(value_json['data']['timings']['Dhuhr'])) | timestamp_custom('%H:%M') }}"
icon: mdi:mosque
- name: "Asr"
unique_id: asr
value_template: >
{% set time_str = value_json['data']['timings']['Asr'] %}
{% set date_time_str = now().date().isoformat() + ' ' + time_str %}
{% set amsterdam_time = as_timestamp(strptime(date_time_str, '%Y-%m-%d %H:%M')) | timestamp_custom('%Y-%m-%dT%H:%M:%S+01:00', 'Europe/Amsterdam') %}
{{ amsterdam_time }}
device_class: timestamp
icon: mdi:mosque
- name: "Asr Readable"
unique_id: asr_readable
value_template: "{{ as_timestamp(today_at(value_json['data']['timings']['Asr'])) | timestamp_custom('%H:%M') }}"
icon: mdi:mosque
- name: "Maghrib"
unique_id: maghrib
value_template: >
{% set time_str = value_json['data']['timings']['Maghrib'] %}
{% set date_time_str = now().date().isoformat() + ' ' + time_str %}
{% set amsterdam_tz = 'Europe/Amsterdam' %}
{% set amsterdam_time = as_timestamp(strptime(date_time_str, '%Y-%m-%d %H:%M')) | timestamp_custom('%Y-%m-%dT%H:%M:%S+01:00', amsterdam_tz) %}
{{ amsterdam_time }}
device_class: timestamp
icon: mdi:mosque
- name: "Maghrib Readable"
unique_id: maghrib_readable
value_template: "{{ as_timestamp(today_at(value_json['data']['timings']['Maghrib'])) | timestamp_custom('%H:%M') }}"
icon: mdi:mosque
- name: "Isha"
unique_id: isha
value_template: >
{% set time_str = value_json['data']['timings']['Isha'] %}
{% set date_time_str = now().date().isoformat() + ' ' + time_str %}
{% set amsterdam_tz = 'Europe/Amsterdam' %}
{% set amsterdam_time = as_timestamp(strptime(date_time_str, '%Y-%m-%d %H:%M')) | timestamp_custom('%Y-%m-%dT%H:%M:%S+01:00', amsterdam_tz) %}
{{ amsterdam_time }}
device_class: timestamp
icon: mdi:mosque
- name: "Isha Readable"
unique_id: isha_readable
value_template: "{{ as_timestamp(today_at(value_json['data']['timings']['Isha'])) | timestamp_custom('%H:%M') }}"
icon: mdi:mosque
- name: "Hijri Date"
unique_id: hijri
value_template: "{{ value_json['data']['date']['hijri']['date'] }}"
icon: mdi:mosque
- name: "Hijri day"
unique_id: hijri_day
value_template: "{{ value_json['data']['date']['hijri']['day'] }}"
icon: mdi:mosque
- name: "Hijri Month"
unique_id: hijri_month
value_template: "{{ value_json['data']['date']['hijri']['month']['en'] }}"
icon: mdi:mosque
- name: "Hijri Year"
unique_id: hijri_year
value_template: "{{ value_json['data']['date']['hijri']['year'] }}"
icon: mdi:mosque
- name: "Islamic Holiday"
unique_id: islamic_holiday
value_template: >
{% if value_json['data']['date']['hijri']['holidays'] %}
({{ value_json['data']['date']['hijri']['holidays'] | replace('[', '') | replace(']', '') | replace("'", '') }})
{% else %}
False
{% endif %}
icon: mdi:star-crescent
code here
Dashboard
type: grid
cards:
- type: tile
entity: sensor.hijri_date
color: green
- type: tile
entity: sensor.imsak_readable
name: Imsak
visibility:
- condition: state
entity: sensor.next_prayer
state: No upcoming prayer
- condition: state
entity: sensor.is_ramadan
state: "true"
features_position: bottom
vertical: false
- type: tile
entity: sensor.next_prayer
color: blue
features_position: bottom
vertical: false
visibility:
- condition: state
entity: sensor.next_prayer
state_not: No upcoming prayer
- condition: state
entity: sensor.is_ramadan
state: "true"
- type: tile
entity: sensor.fajr_readable
name: Fajr
color: accent
- type: tile
entity: sensor.dhuhr_readable
name: Dhuhr
color: accent
- type: tile
entity: sensor.asr_readable
name: Asr
color: accent
- type: tile
entity: sensor.maghrib_readable
name: Maghrib
color: accent
- type: tile
entity: sensor.isha_readable
name: Isha
color: accent
- type: tile
entity: sensor.moon_phase
grid_options:
columns: 6
rows: 1
color: deep-orange
visibility:
- condition: state
entity: automation.ramdan_imsak
state: "off"
- type: tile
entity: sensor.islamic_holiday
features_position: bottom
vertical: false
visibility:
- condition: state
entity: sensor.islamic_holiday
state_not: "False"
Automatisation
alias: Adhan ✅
description: ""
triggers:
- at: sensor.asr
id: Asr
trigger: time
- at: sensor.dhuhr
id: Dhuhr
trigger: time
- at: sensor.fajr
id: Fajr
trigger: time
- id: Maghrib
at: sensor.maghrib
trigger: time
- at: sensor.isha
id: Isha
trigger: time
- at: "00:30:00"
enabled: true
id: update_api
alias: Update API
trigger: time
conditions:
- condition: state
entity_id: input_boolean.adhan
state: "on"
actions:
- action: notify.mobile_app_iphone_johann
metadata: {}
data:
message: Adhan > {{ trigger.id }}
enabled: false
- parallel:
- metadata: {}
data:
duration: 150
blink: "500"
message: adhan
icon: "2628"
pushing_the_icon: 0= Icon doesn't move
action: script.awtrix_notification
enabled: false
- choose:
- conditions:
- condition: time
after: "22:00:00"
before: "10:00:00"
weekday:
- sun
- mon
- tue
- wed
- fri
- thu
- sat
sequence:
- alias: Set volume
metadata: {}
data:
volume_level: 0.05
action: media_player.volume_set
target:
entity_id: media_player.adhan_speakers
default:
- metadata: {}
data:
volume_level: 0.3
action: media_player.volume_set
target:
entity_id: media_player.adhan_speakers
- choose:
- conditions:
- condition: trigger
id:
- Fajr
sequence:
- metadata: {}
data:
volume_level: 0.04
target:
entity_id:
- media_player.adhan_speakers
action: media_player.volume_set
- data:
media_content_type: music
media_content_id: /media/local/adhan/02-02-adhan-day.mp3
announce: true
target:
entity_id:
- media_player.adhan_speakers
action: media_player.play_media
- conditions:
- condition: trigger
id:
- Asr
- Dhuhr
- Maghrib
- Isha
sequence:
- alias: Adhan MP3
data:
media_content_type: music
media_content_id: /media/local/adhan/03-01-adhan-day.mp3
announce: true
action: media_player.play_media
target:
entity_id: media_player.adhan_speakers
- conditions:
- condition: trigger
id:
- update_api
sequence:
- data:
entity_id:
- sensor.asr
target:
entity_id:
- sensor.asr
action: homeassistant.update_entity
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- data:
message: "Pray Times Are Updated. "
entity_id: automation.adhan
name: Adhan
action: logbook.log
mode: single
Pre announcement (for Wudu)
alias: Adhan Preannouncement ✅
description: ""
triggers:
- alias: Fajr
value_template: |-
{% set fajr_timestamp = as_timestamp(states('sensor.fajr')) %}
{% set current_timestamp = as_timestamp(now()) %}
{{ fajr_timestamp - 300 <= current_timestamp < fajr_timestamp - 290 }}
id: Fajr
trigger: template
- alias: Dhuhr
value_template: |-
{% set dhuhr_timestamp = as_timestamp(states('sensor.dhuhr')) %}
{% set current_timestamp = as_timestamp(now()) %}
{{ dhuhr_timestamp - 600 <= current_timestamp < dhuhr_timestamp - 590 or
dhuhr_timestamp - 300 <= current_timestamp < dhuhr_timestamp - 290 }}
trigger: template
- alias: Asr
value_template: |-
{% set asr_timestamp = as_timestamp(states('sensor.asr')) %}
{% set current_timestamp = as_timestamp(now()) %}
{{ asr_timestamp - 600 <= current_timestamp < asr_timestamp - 590 or
asr_timestamp - 300 <= current_timestamp < asr_timestamp - 290 }}
trigger: template
- alias: Maghrib
value_template: >-
{% set maghrib_timestamp = as_timestamp(states('sensor.maghrib')) %}
{% set current_timestamp = as_timestamp(now()) %}
{{ maghrib_timestamp - 600 <= current_timestamp < maghrib_timestamp - 590
or
maghrib_timestamp - 300 <= current_timestamp < maghrib_timestamp - 290 }}
trigger: template
- alias: Isha
value_template: |-
{% set isha_timestamp = as_timestamp(states('sensor.isha')) %}
{% set current_timestamp = as_timestamp(now()) %}
{{ isha_timestamp - 600 <= current_timestamp < isha_timestamp - 590 or
isha_timestamp - 300 <= current_timestamp < isha_timestamp - 290 }}
trigger: template
conditions:
- condition: state
entity_id: input_boolean.adhan
state: "on"
actions:
- data:
message: Adhan pre announcement!
action: notify.mobile_app_iphone_johann
- if:
- condition: trigger
id:
- Fajr
then:
- data:
chime_path: /media/sounds/airport-announcement.mp3
tts_platform: cloud
volume_level: 0.24
join_players: true
unjoin_players: true
language: ar-SA
voice: HamedNeural
message: انتبه سيدي، الأذان في دقائق، شكرا
announce: true
fade_audio: true
action: chime_tts.say
target:
entity_id: media_player.announcement
else:
- if:
- condition: state
entity_id: input_boolean.bedtime_mode
state: "off"
then:
- data:
chime_path: soft
tts_platform: cloud
volume_level: 0.2
join_players: true
unjoin_players: true
announce: true
language: ar-SA
voice: HamedNeural
message: انتبه سيدي، الأذان في دقائق، شكرا
action: chime_tts.say
target:
entity_id: media_player.announcement
else:
- data:
chime_path: soft
tts_platform: cloud
volume_level: 0.19
language: ar-SA
voice: HamedNeural
message: انتبه سيدي، الأذان في دقائق، شكرا
announce: true
action: chime_tts.say
target:
entity_id: media_player.announcement
mode: single
I’m also planning to make an integration but after Eid inshallah.
Assalamu alaikum wa ra7matou lahy wa barakatou brothers.
I don’t know if it is of any interest but I am using two integrations “Islamic Prayer Times” with MWL calculation and Mawaqit via HACS.
The first one I use for displaying the prayer times for the day and for the athan automation. And I use the Mawaqit integration to know when the Jumu’a Khutba and prayer starts. It looks like this:
You can see in edit mode, that my Jumua badge is hidden and is only shown on fridays. So I used some conditions that on fridays my Jumua badge replaces my dhuhr badge. So I always get the latest updates from my local mosque.