How do you add code in a “code box”?
Does anyone know how i could integrate these times?
I have got it working with the aladhan API but struggling with this
…these are times for the whole year
I’ve managed to get the times via another API but still interested to know how to work with the above if anyone knows
We use actual sightings instead of calculated. However, I think that you could look at my example. it may help. My current experiment is to pull the database locally instead of using the API.
Do you mind sharing which API please?
I’m trying to use the same website but as it’s the whole year, I don’t know how to get it to show only the current day.
If you do get it working, please let me know.
Click on the button on the post/reply box ruler that looks like </>
thanks for the feedback.
I have this running on all my LG WebOS and also on Android Box hooked to my TV. The LG WebOS gets woken up and adhan played and powers off. This is tweaked for Hanafi timing for India location (longituted and latitude should be changed for you) and also uses the same API in this thread…Thanks to everyone contribution (i have merely aggregated for my environment) this is really helpful to my family as this reminder has been working flawlessly.
config.yaml
media_player:
-
platform: androidtv
adb_server_ip: "127.0.0.1"
adb_server_port: 5037
get_sources: true
host: "IPAddrofTV"
name: “AirtelLivingRoomTV”
-
platform: androidtv
adb_server_ip: "127.0.0.1"
adb_server_port: 5037
get_sources: true
host: "IPAddrofTV"
name: "AirtelParentRoomTV"
-
platform: lg_netcast
host: IPAddrofTV
access_token: xxxxx
turn_on_action:
service: switch.turn_on
data:
entity_id: switch.tv_switch
wake_on_lan:
webostv:
# LG TV
host: IPAddrofTV
name: LG TV
turn_on_action:
service: wake_on_lan.send_magic_packet
data:
mac: xx:xx:xx:xx:xx:xx
weather:
- platform: darksky
api_key: !secret darksky_api
notify:
-
host: "IPAddrofTV"
name: LivingRoomTV
platform: nfandroidtv
-
host: "IPAddrofTV"
name: ParentRoomTV
platform: nfandroidtv
tts:
-
platform: google_translate
media_extractor:
group: !include_dir_merge_named groups
automation: !include automations.yaml
script: !include_dir_merge_named scripts
scene: !include scenes.yaml
sensor: !include sensors.yaml
input_select: !include input_select.yaml
light: !include lights.yaml
fan: !include fans.yaml
timer: !include timers.yaml
sensor.yaml (Contains all the adhan timings as sensors for matchin g them as template in automation.yaml_)
- platform: rest
name: Prayer_Times
json_attributes:
- data
resource: http://api.aladhan.com/v1/timings?latitude=xx.xxx&longitude=xx.xxx&method=1&school=1
value_template: '{{ value_json["data"]["meta"]["method"]["name"].title() }}'
scan_interval: 86400
- platform: template
sensors:
fajr:
friendly_name: 'Fajr'
value_template: '{{ states.sensor.prayer_times.attributes.data.timings["Fajr"] | timestamp_custom("%H:%M") }}'
dhuhr:
friendly_name: 'Dhuhr'
value_template: '{{ states.sensor.prayer_times.attributes.data.timings["Dhuhr"] | timestamp_custom("%H:%M") }}'
asr:
friendly_name: 'Asr'
value_template: '{{ states.sensor.prayer_times.attributes.data.timings["Asr"] | timestamp_custom("%H:%M") }}'
maghrib:
friendly_name: 'Maghrib'
value_template: '{{ states.sensor.prayer_times.attributes.data.timings["Maghrib"] | timestamp_custom("%H:%M") }}'
isha:
friendly_name: 'Isha'
value_template: '{{ states.sensor.prayer_times.attributes.data.timings["Isha"] | timestamp_custom("%H:%M") }}'
tahajjud:
friendly_name: 'Tahajjud'
value_template: '{{ states.sensor.prayer_times.attributes.data.timings["Imsak"] | timestamp_custom("%H:%M") }}'
hijri_date:
friendly_name: 'Hijri_Date'
value_template: '{{ states.sensor.prayer_times.attributes.data.date.hijri.date}}'
hijri_month:
friendly_name: 'Hijri_Month'
value_template: '{{ states.sensor.prayer_times.attributes.data.date.hijri.month["en"]}}'
#sensor:
- platform: time_date
display_options:
- time
- date
- date_time
- time_date
- time_utc
- beat
scripts/tv_power.yaml (Powers on or off all TV/Android box)
'1588673487571':
alias: PowerOnLivingRoom
sequence:
- condition: state
entity_id: media_player.airtellivingroomtv
state: 'off'
- data:
command: POWER
entity_id: media_player.airtellivingroomtv
entity_id: media_player.airtellivingroomtv
service: androidtv.adb_command
- data: {}
entity_id: media_player.airtellivingroomtv
service: media_player.turn_on
mode: single
'1588673643400':
alias: PowerOFFLivingRoomFFTV
sequence:
- delay: 00:07:30
- data:
entity_id: media_player.lg_tv_3
entity_id: media_player.lg_tv_3
service: media_player.turn_off
- data:
command: POWER
entity_id: media_player.airtellivingroomtv
entity_id: media_player.airtellivingroomtv
service: androidtv.adb_command
- data:
command: POWER
entity_id: media_player.airtelparentroomtv
service: media_player.airtelparentroomtv
mode: single
'1589372900912':
alias: PowerOnUpperLivingLGTV
sequence:
- data:
broadcast_address: IPAddrofTV
broadcast_port: 9
mac: xx:xx:xx:xx:xx:xx
service: wake_on_lan.send_magic_packet
- data:
entity_id: media_player.lg_tv_3
volume_level: '0.2'
entity_id: media_player.lg_tv_3
service: media_player.volume_set
'1599288686140':
alias: PowerONParentTV
mode: single
sequence:
- condition: state
entity_id: media_player.airtelparentroomtv
state: 'off'
- data:
command: POWER
entity_id: media_player.airtelparentroomtv
entity_id: media_player.airtelparentroomtv
service: androidtv.adb_command
- data: {}
entity_id: media_player.airtelparentroomtv
service: media_player.turn_on
scripts/adhan.yaml (have a folder called scripts for splitting various scripts but included in config.yaml)
'1587919903513':
alias: PlayRestAdhanLivingRoomTV
sequence:
- delay: 00:00:20
- data:
entity_id: media_player.lg_tv_3
volume_level: '0.2'
entity_id: media_player.lg_tv_3
service: media_player.volume_set
- data:
command: system.launcher/open
entity_id: media_player.lg_tv_3
payload:
target: http://<IP of my NAS>/web/Adhan/MasjidHaram.mp3
entity_id: media_player.lg_tv_3
service: webostv.command
- data:
message: GO FOR PRAYERS NOW
service: notify.lg_tv
- data:
command: am start -a android.intent.action.VIEW
"http://<IP of my NAS>/web/Adhan/MasjidHaram.mp3"
entity_id: media_player.airtellivingroomtv
entity_id: media_player.airtellivingroomtv
service: androidtv.adb_command
- data:
command: am start -a android.intent.action.VIEW
"http://<IP of my NAS/web/Adhan/MasjidHaram.mp3"
entity_id: media_player.airtelparentroomtv
entity_id: media_player.airtelparentroomtv
service: androidtv.adb_command
- data:
message: Prayer Time
service: notify.parentroomtv
mode: single
'1588420846222':
alias: PlayFajrAdhanLivingRoomTV
sequence:
- delay: 00:00:30
- data:
entity_id: media_player.lg_tv_3
volume_level: '0.2'
entity_id: media_player.lg_tv_3
service: media_player.volume_set
- data:
message: Prayer Time
service: notify.lg_tv
- data:
command: system.launcher/open
entity_id: media_player.lg_tv_3
payload:
target: http://<IP of NAS>/web/Adhan/FajrAdhan.mp3
entity_id: media_player.lg_tv_3
service: webostv.command
- data:
message: Prayer Time
service: notify.parentroomtv
- data:
command: am start -a android.intent.action.VIEW "http://<IP OF NAS>/web/Adhan/FajrAdhan.mp3"
entity_id: media_player.airtellivingroomtv
entity_id: media_player.airtellivingroomtv
service: androidtv.adb_command
- data:
command: am start -a android.intent.action.VIEW "http://<IPOF NAS>/web/Adhan/FajrAdhan.mp3"
entity_id: media_player.airtelparentroomtv
entity_id: media_player.airtelparentroomtv
service: androidtv.adb_command
mode: single
automation.yaml (This matches sensor time and invokes the script for power on and adhan file to be played). Each of the script referred here turns on. each of the TV, starts a timer, play adhan and then executes a script to turn off.
- id: '1517693034928'
alias: Suhoor
trigger:
- platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time_date"), "%H:%M"))
== as_timestamp(strptime(states("sensor.fajr"), "%H:%M")) - 1800 }}'
condition: []
action:
- data: {}
entity_id: media_player.airtellivingroomtv
service: media_player.turn_on
- data: {}
entity_id: script.1587919903513
service: script.turn_on
- id: '1517693034923'
alias: Adhan Fajr
trigger:
- platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time"), "%H:%M")) ==
as_timestamp(strptime(states("sensor.fajr"), "%H:%M")) }}'
condition: []
action:
- data: {}
entity_id: script.1589372900912
service: script.turn_on
- data:
entity_id: media_player.airtelparentroomtv
entity_id: media_player.airtelparentroomtv
service: media_player.turn_on
- data: {}
entity_id: script.1588673487571
service: script.turn_on
- data: {}
entity_id: script.1599288686140
service: script.turn_on
- entity_id: script.1588420846222
service: script.turn_on
- data: {}
entity_id: script.1588673643400
service: script.turn_on
mode: single
- id: '1517693010924'
alias: Adhan Zhuhr
trigger:
- platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time"), "%H:%M")) ==
as_timestamp(strptime(states("sensor.dhuhr"), "%H:%M")) }}'
condition: []
action:
- data: {}
entity_id: script.1589372900912
service: script.turn_on
- data: {}
entity_id: script.1588673487571
service: script.turn_on
- data:
entity_id: media_player.airtelparentroomtv
entity_id: script.1599288686140
service: script.turn_on
- data: {}
entity_id: script.1587919903513
service: script.turn_on
- data: {}
entity_id: script.1588673643400
service: script.turn_on
mode: single
- id: '1517693010925'
alias: Adhan Asr
trigger:
- platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time"), "%H:%M")) ==
as_timestamp(strptime(states("sensor.asr"), "%H:%M")) }}'
condition: []
action:
- data: {}
entity_id: script.1589372900912
service: script.turn_on
- data: {}
entity_id: script.1588673487571
service: script.turn_on
- data: {}
entity_id: script.1599288686140
service: script.turn_on
- data: {}
entity_id: script.1587919903513
service: script.turn_on
- data: {}
entity_id: script.1588673643400
service: script.turn_on
mode: single
- id: '1517693010926'
alias: Adhan Maghrib
trigger:
- platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time"), "%H:%M")) ==
as_timestamp(strptime(states("sensor.maghrib"), "%H:%M")) }}'
condition: []
action:
- data: {}
entity_id: script.1589372900912
service: script.turn_on
- data: {}
entity_id: script.1588673487571
service: script.turn_on
- data: {}
entity_id: script.1599288686140
service: script.turn_on
- data: {}
entity_id: script.1587919903513
service: script.turn_on
- data: {}
entity_id: script.1588673643400
service: script.turn_on
mode: single
- id: '1517693010927'
alias: Adhan Isha
trigger:
- platform: template
value_template: '{{ as_timestamp(strptime(states("sensor.time"), "%H:%M")) ==
as_timestamp(strptime(states("sensor.isha"), "%H:%M")) }}'
condition: []
action:
- data: {}
entity_id: script.1589372900912
service: script.turn_on
- data: {}
entity_id: script.1588673487571
service: script.turn_on
- data: {}
entity_id: script.1599288686140
service: script.turn_on
- data: {}
entity_id: script.1587919903513
service: script.turn_on
- data: {}
entity_id: script.1588673643400
service: script.turn_on
mode: single
Salam…
nice config
i use islamic prayer time component on my side, but i am interesting to use hijri date and month like in your configuration.
can it combine with HA prayer time and just put hijri date etc from aladhan ?
I am using all prayer times + Hijri date time on an entities card from the site api. You can add the sensor and use/display the hijri date and time only from the site - details are in sensor.yaml
I have both times added as sensor but leverage the site not ha since I needed the Hanafi prayer times which the site was giving
Hope this helps
thank you so much for your info
Assalamu allaikum
I have integrated prayer time in my home assistant. How do I run the mp3 file that I have stored in the local directory 5 minutes before the call to prayer
I have not done that. but did you try delay with a negative? e.g.
“-00:05:00”
Hi guys, anyone was able to integrate Aladhan to Home Assist??
did my suggestion work
I set up a volumio instance on a pi, and call that
I would like to use this as Islamic Prayer Time integration because AlAdhan APi have Turkish Diyanet calculation method. I am not expert in HA.
Can you help me?
If i add the codes in configuration an automation will it work? Also can i add as card in the dashboard?
@shehzan does the automation work? and are you able to add as card in your dashboard? I am verry interested switching from Islamic Prayer Time to Aladhan because it have Turkish Diyanet calculation method…