Does anyone know how to modify the automation to do daylight saving?
It was working fine until we set the clock to +1 today
I need help with that too. Now that we moved 1 hour ahead how do we update Athan timing ?
This is not working for daylight saving because the sensors are in UTC
Jzk, I’m guessing this only works using yaml directly and not the UI?
It was fixed the next day after the switch to DST. I opened an issue with the developers
Oh, I’m aware of that, I meant the UI doesn’t support (show) multiple trigger entities, only via yaml. Jzk
Salaam ou alaikum, Can anyone help me with the following. I cannot adjust the prayer times
Jazakallah khair
Salaam ou Alaikoum Brothers,
Do any of you know how I can add Hijri calendar to the prayer times?
I would like to know also. How do we create offsets, or use London based timings?
For anyone who wish to have offset configurable without restarting HA and also in addition to that I play the quran everyday before the Magrib prayer. I am a newbie with HA and with the help of all the posts here I was able to make some changes for my need.
All the media files I kept it local and not relying on the internet.
I have added the Islamic Prayer Times using the integration. And using the prayer sensors, I have built as below
I have done all the configuration through the UI and below is the automation I have created for the prayer time to be played on my google nest
alias: Play Azaan for Rest
description: ''
trigger:
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.dhuhr_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_dhuhr")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.asr_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_asr")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.maghrib_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_maghrib")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.isha_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_isha")) }}
condition: []
action:
- service: media_player.play_media
data:
media_content_id: 'http://192.168.86.20:8143/local/sound/azan3.mp3'
media_content_type: audio/mp3
target:
entity_id: media_player.all_speakers
- service: media_player.volume_set
data:
volume_level: 0.5
target:
entity_id: media_player.bedroom_wifi
- service: media_player.volume_set
data:
volume_level: 0.3
target:
entity_id: media_player.studyroom_wifi
- service: media_player.volume_set
data:
volume_level: 0.7
target:
entity_id: media_player.kitchen_speaker
mode: single
Below is one of the input text I had created for the offset. Which can be updated anytime. Set the value to be in seconds and also I had to make sure the seconds I set always converts to an integer minute. If not the automation does not trigger.
Below are the details on how I play the quran everyday and finishes couple of seconds before Magrib prayer. Two helpers used here, a counter to keep track of the juz and input text to save the media duration.
alias: Get Media Duration
description: ''
trigger:
- platform: time
at: '06:00'
condition: []
action:
- service: media_player.volume_mute
data:
is_volume_muted: true
target:
entity_id: media_player.kitchen_speaker
- service: media_player.play_media
data:
media_content_type: video/mp4
media_content_id: >-
media-source://media_source/local/quran/Para{{states("counter.juzcounter")}}.mp3
entity_id: media_player.kitchen_speaker
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: input_text.set_value
data:
value: >
{% set actual_duration =
state_attr("media_player.kitchen_speaker","media_duration") | round(0)
%} {% set duration_in_min = (actual_duration/60)|round(0)%} {% if
(duration_in_min*60) > actual_duration -%} {% set duration_update =
duration_in_min*60 %} {%- else -%} {% set duration_update =
(duration_in_min*60) + 60 %} {%- endif %} {{duration_update}}
target:
entity_id: input_text.mediaduration
- service: media_player.media_stop
data: {}
target:
entity_id: media_player.kitchen_speaker
- service: media_player.volume_mute
target:
entity_id: media_player.kitchen_speaker
data:
is_volume_muted: false
- service: media_player.turn_off
target:
entity_id: media_player.kitchen_speaker
mode: single
alias: Play Quran before Magrib
description: ''
trigger:
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.maghrib_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_maghrib")) -
float(states("input_text.mediaduration")) }}
condition: []
action:
- service: media_player.volume_set
data:
volume_level: 0.3
target:
entity_id: media_player.all_speakers
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: media_player.play_media
data:
media_content_type: video/mp4
media_content_id: >-
media-source://media_source/local/quran/Para{{states("counter.juzcounter")}}.mp3
entity_id: media_player.all_speakers
- service: script.increment_and_reset_juz_counter
mode: single
alias: Increment and Reset Juz Counter
sequence:
- choose:
- conditions:
- condition: state
entity_id: counter.juzcounter
state: '30'
sequence:
- service: counter.reset
target:
entity_id: counter.juzcounter
default:
- service: counter.increment
target:
entity_id: counter.juzcounter
mode: single
I have saved all the (30) juz/para of the Quran in my media and using the juzcounter dynamically I play it one by one daily and resets once it reaches 30.
counter:
juzcounter:
initial: 1
step: 1
maximum: 30
minimum: 1
Hope it can help someone.
@rr86 JazakAllah Khair, very nice setup!
I’ve used your offset method, but can’t figure out how to reduce the offset after creating the input_select
, nothing updates on the Islamic Prayer sensor. Would appreciate help, jzk.
@hazio it will not update the Islamic Prayer sensors.
I have used additional sensors to monitor the actual time of the prayer with the offsets.
configuration.yaml
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'time_date'
- 'date_time'
- platform: template
sensors:
salah_fajr:
friendly_name: "Salah Fajr"
value_template: >
{{((as_timestamp(strptime(states("sensor.fajr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_fajr")) )| timestamp_custom ('%r')}}
salah_dhuhr:
friendly_name: "Salah Dhuhr"
value_template: >
{{((as_timestamp(strptime(states("sensor.dhuhr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_dhuhr")) )| timestamp_custom ('%r')}}
salah_asr:
friendly_name: "Salah Asr"
value_template: >
{{((as_timestamp(strptime(states("sensor.asr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_asr")) )| timestamp_custom ('%r')}}
salah_maghrib:
friendly_name: "Salah Maghrib"
value_template: >
{{((as_timestamp(strptime(states("sensor.maghrib_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_maghrib")) )| timestamp_custom ('%r')}}
salah_isha:
friendly_name: "Salah Isha"
value_template: >
{{((as_timestamp(strptime(states("sensor.isha_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_isha")) )| timestamp_custom ('%r')}}
quran_time:
friendly_name: "Quran Time"
value_template: >
{{ (as_timestamp(strptime(states("sensor.maghrib_prayer"), "%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_maghrib")) - float(states("input_text.mediaduration")) )| timestamp_custom ('%r')}}
And I added a view to lovelace to show the time from these sensors configured
If you see my automations in my previous post, I have used the Prayer time sensor + offset for trigger.
So in your case, I believe you need to use the Prayer time sensors + input_selection to get the actual time for the prayer.
Could you explain more on this? I’m fairly new when it comes to setting up input_select, thanks
In the helper create an input select and add the required options you need. Make sure the options are in seconds.
Then change the value under configuration by selecting one of the options added earlier
The input select created above then can be used as below for a time sensor or for the trigger.
sensors:
salah_fajr:
friendly_name: "Salah Fajr"
value_template: >
{{((as_timestamp(strptime(states("sensor.fajr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_select.offsetselection")) )| timestamp_custom ('%r')}}
Guys i need to setup the correct times for the Azan on my local time, now looks to makkah but it should be different. I will do it for Netherlands and the time from Diyanet.
So I can use a single entity which will be offsetted by the options created on the dialogue config in order, or do I need to create a indiviual input select for each salah sensor, i.e input_select.asr
etc…? jzk
@hazio if the offset time is the same across all the prayer time then you can use one.
In my case, I had to adjust for each prayer time by couple of minutes up and down thus I created individually for all prayer time.
im trying to use your code to get the offset working. all these while i’ve just been using the default prayer sensor. Now that ramdhan is around the corner, i have to make sure it is following my local timing.
here is my code (config) after copying it from yours.
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'time_date'
- 'date_time'
- platform: template
sensors:
salah_fajr:
friendly_name: "Salah Fajr"
value_template: >
{{((as_timestamp(strptime(states("sensor.fajr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_fajr")) )| timestamp_custom ('%r')}}
salah_dhuhr:
friendly_name: "Salah Dhuhr"
value_template: >
{{((as_timestamp(strptime(states("sensor.dhuhr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_dhuhr")) )| timestamp_custom ('%r')}}
salah_asr:
friendly_name: "Salah Asr"
value_template: >
{{((as_timestamp(strptime(states("sensor.asr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_asr")) )| timestamp_custom ('%r')}}
salah_maghrib:
friendly_name: "Salah Maghrib"
value_template: >
{{((as_timestamp(strptime(states("sensor.maghrib_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_maghrib")) )| timestamp_custom ('%r')}}
salah_isha:
friendly_name: "Salah Isha"
value_template: >
{{((as_timestamp(strptime(states("sensor.isha_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_text.offset_isha")) )| timestamp_custom ('%r')}}
quran_time:
friendly_name: "Quran Time"
value_template: >
{{ (as_timestamp(strptime(states("sensor.maghrib_prayer"), "%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_maghrib")) - float(states("input_text.mediaduration")) )| timestamp_custom ('%r')}}
I haven’t changed anything here.
Then i tried to open up the entity to put in the offset values and it gives me this error.
im at a lost here as i do not know how to input the offset.
Here’s my automation script. Hope u can assist me.
- alias: Azan
trigger:
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.dhuhr_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_dhuhr")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.asr_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_asr")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.maghrib_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_maghrib")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.isha_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_text.offset_isha")) }}
condition: []
action:
- service: media_extractor.play_media
data:
entity_id: media_player.living_speaker
media_content_id: https://www.dropbox.com/s/zr93i3be3gmdhap/Omar%20%20Hana%20%20Adhan%20%20Islamic%20cartoons%20for%20kids.mp3?dl=0
media_content_type: music
- service: media_player.volume_set
data:
entity_id: media_player.living_speaker
volume_level: '0.9'
mode: single
ok not to worry - i think i got the codes working.
here is my config:
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'time_date'
- 'date_time'
- platform: template
sensors:
salah_dhuhr:
friendly_name: "Salah Zohor"
value_template: >
{{((as_timestamp(strptime(states("sensor.dhuhr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_select.offset_zohor")) )| timestamp_custom ('%r')}}
salah_asr:
friendly_name: "Salah Asar"
value_template: >
{{((as_timestamp(strptime(states("sensor.asr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_select.offset_asar")) )| timestamp_custom ('%r')}}
salah_maghrib:
friendly_name: "Salah Maghrib"
value_template: >
{{((as_timestamp(strptime(states("sensor.maghrib_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_select.offset_maghrib")) )| timestamp_custom ('%r')}}
salah_isha:
friendly_name: "Salah Isyak"
value_template: >
{{((as_timestamp(strptime(states("sensor.isha_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_select.offset_isyak")) )| timestamp_custom ('%r')}}
salah_fajr:
friendly_name: "Salah Subuh"
value_template: >
{{((as_timestamp(strptime(states("sensor.fajr_prayer"), "%Y-%m-%dT%H:%M:%S"))) + float(states("input_select.offset_subuh")) )| timestamp_custom ('%r')}}
here’s my auto:
- alias: Azan
trigger:
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.dhuhr_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_select.offset_zohor")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.asr_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_select.offset_asar")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.maghrib_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_select.offset_maghrib")) }}
- platform: template
value_template: >-
{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d"))
== as_timestamp(strptime(states("sensor.isha_prayer"),
"%Y-%m-%dT%H:%M:%S")) + float(states("input_select.offset_isyak")) }}
condition: []
action:
- service: media_extractor.play_media
data:
entity_id: media_player.living_speaker
media_content_id: https://www.dropbox.com/s/zr93i3be3gmdhap/Omar%20%20Hana%20%20Adhan%20%20Islamic%20cartoons%20for%20kids.mp3?dl=0
media_content_type: music
- service: media_player.volume_set
data:
entity_id: media_player.living_speaker
volume_level: '0.9'
hope it works with the offset timing. thanks @rr86 for your work around on the offset.