Hi @ax4world , this looks amazing, do you have step by step instructions? Appreciate it
@123 Hi Taras, you are incredible helpful so I wanted to ask for help.
I am using the Islamic Times and Sonos integration but the automated athan is failing. This is what I have in my automations.yaml file:
- id: '2021061302'
alias: Azan
triggers:
- at:
- sensor.fajr_prayer
- sensor.dhuhr_prayer
- sensor.asr_prayer
- sensor.maghrib_prayer
- sensor.isha_prayer
trigger: time
actions:
- target:
entity_id: media_player.office
data:
volume_level: 1
action: media_player.volume_set
- target:
entity_id: media_player.office
data:
media_content_id: https://islamcan.com/audio/adhan/azan1.mp3
media_content_type: music
action: media_player.play_media
I have not added anything to my configuration.yaml file. When I go to settings->automation I do see the automation and can manually trigger and play it. I am thinking that perhaps something is wrong the Islamic time sensors. Any help would be greatly appreciated.
First thing to check is to confirm that the automation is not disabled.
If the automation is enabled and the Time Trigger isnât triggering the automation at the scheduled times reported by the sensors then it implies the sensors are at fault.
Go to Developer Tools â States and look at the values of the following sensors:
- sensor.fajr_prayer
- sensor.dhuhr_prayer
- sensor.asr_prayer
- sensor.maghrib_prayer
- sensor.isha_prayer
Confirm the values are correct. If theyâre incorrect then it suggests a problem with the Islamic Prayer Times integration.
If everything seems to be in order yet the automation doesnât trigger then I donât what else to suggest.
As Salaams
Can anyone assist with my automation i posted at the link below
I was able to successfully scrape the time and it is displaying correctly but it does not trigger the automation
Would appreciate any assistance
Hi @123,
It seems that the sensor names for the Islamic Time integration are now different. Once I updated them, it all started working. Thank you for pointing me to the right direction!
Can I ask two more questions? First, I would like to automatically play Surah baqara at a certain time (like 10am). How can I do that?
Second, you are so experienced here but I am a total newbie. Would you recommend any book or resource to get better at this?
Thank you again!
Does your automation work if you manually trigger it (settings->automation)? I had a similar issue where my automation did not work because I was referring to a trigger sensor with the wrong name.
Hi
Yes it does trigger when i run the automation manually, plays the athaan on the speaker
I think the issue is the value template i am using to convert the data I am scraping from the website, its not been parsed as a valid date/time stamp
this can also be seen on the states screen
i am expecting to see the timestamp attribute on the sensor and this is missing
To do something, like play a song at a specific time, use a Time Trigger. For example:
- id: '2021061302'
alias: Azan
triggers:
- trigger: time
at: '10:00:00'
actions:
- target:
entity_id: media_player.office
data:
volume_level: 1
action: media_player.volume_set
- target:
entity_id: media_player.office
data:
media_content_id: insert URL to whatever you want to play here
media_content_type: music
action: media_player.play_media
Iâm unaware of any books for Home Assistant. What I have learned comes from reading the official documentation and this community forum.
Hi @123
Would you be able to advise on my issue, would appreciate any assistance or pointers.
A Time Trigger accepts the use of a sensor but only if the sensorâs device_class
is timestamp
and the sensorâs value is a datetime value in ISO format.
Time Trigger - Sensors of datetime device class
If the scrape sensor you created fails to meet this important criteria, it will not work in a Time Trigger.
thank you
the scrape sensor currently only gives the time in a 24 hour clock. e.g. 17:00
what would i need to do to make it a valid timestamp.
currently using the below:
{{ today_at(value) | as_timestamp | timestamp_custom('%H:%M') }}
but not working as expected
Where are you using that template? Directly in the scrape sensor? (I am unfamiliar with the scrape sensor youâre using)
im using the HA Scrape integration
Im currently setting it up via GUI. see below
there is an option to select a device class, when selecting timestamp as class the sensor shows unavailable.
im able to scrape the time off the salaah website, i need to convert the time into a valid timestamp to trigger the automation.
automation works, when triggering manually but the time trigger is not working as expected
Because thatâs just one of the two things that are required to make it a proper Timestamp Sensor. If you review my previous post, I said:
and the sensorâs value is a datetime value in ISO format
So in addition to setting its device_class
to timestamp
, its value must be in the correct format. It cannot simply be the time.
Change the sensorâs template to this:
{{ today_at(value).isoformat() }}
The assumption here is that the value
variable contains a string representing the time in HH:MM format (like 10:35).
Awesome thank you!! that worked, many thanks for your guidance and patience
One question, which is more me being pedantic
With your suggestion the time is reflecting in AM/PM
any chance I can get it to show in military time like before i.e. 17:00âŠ18:00
i tried
{{ today_at(value).isoformat() | timestamp_custom('%H:%M') }}
but did not work
Youâre welcome!
If you change the value so itâs no longer in ISO datetime format, it will cease to function as a Timestamp Sensor (and will not work in a Time Trigger).
understood, cant thank you enough for all your assistance
Was Maghrib salaah few min ago and athaan was played on my speaker⊠been battling for ages trying to get it right for my local region
@123 I hope you are wellâŠis there any way to simply create a random number? Use case, letâs say I have 12 mp3 files labeled 1-12[.mp3], and I want Home Assistant to randomly choose one and play it.
data:
media_content_id: https://islamcan.com/audio/adhan/1.mp3. #random variable would replace the static value of 1 here, for example
media_content_type: music
This template will report a random number from 1 to 12.
{{ range(1,13) | random }}
The range()
function has two parameters, the first is the starting value (1) and the second is one more than the desired ending value (so you use 13 if you want 12). The random
filter randomly selects a number from the sequence of numbers produced by range
.
You can use it like this:
data:
media_content_id: https://islamcan.com/audio/adhan/{{ range(1,13) | random }}.mp3
media_content_type: music
I was able to play live from the ELM mixlr stream. Let me know if anyone is interested