forked from zubir2k/HomeAssistantAdzan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esolat.yaml
231 lines (228 loc) · 18 KB
/
esolat.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
## Malaysia prayer time based on JAKIM Official API
## Version 3.0 - Location and source can be selected from input_select and input_text.
## IMPORTANT NOTE: NO CHANGES IS REQUIRED TO THIS FILE. CONFIGURATION IS SET AT INPUT TEXT AND INPUT SELECT.
## Hijri Date API ##
- platform: rest
resource_template: "http://api.aladhan.com/v1/gToH?adjustment=1&date={{ now().strftime('%d-%m-%Y') }}"
name: HijriDate API
json_attributes_path: "$.data.hijri"
json_attributes:
- day
- month
- year
- holiday
value_template: "{{ value_json.data.hijri.date }}"
## Hijri Date Sensor ##
- platform: template
sensors:
hijridate:
friendly_name: "Hijri Date"
icon_template: mdi:calendar
value_template: >-
{% set months = ["Muharram", "Safar", "Rabi\'ul Awwal", "Rabi\'ul Akhir", "Jamadil Awwal", "Jamadil Akhir", "Rejab", "Sha\'aban", "Ramadhan", "Syawal", "Zulkaedah", "Zulhijjah"] %}
{% set yearday = now().strftime("%j") | int %}
{%if is_state("input_select.solat", "eSolat")%}{{ state_attr("sensor.solat_jakim", "prayerTime")[0].hijri[8:10] }} {{ months[(state_attr("sensor.solat_jakim", "prayerTime")[0].hijri[5:7] | int)-1] }} {{ state_attr("sensor.solat_jakim", "prayerTime")[0].hijri[0:4] }}h
{%elif is_state("input_select.solat", "AzanPro")%}{{ state_attr('sensor.solat_azanpro', 'prayer_times').hijri[8:10] }} {{ months[(state_attr('sensor.solat_azanpro', 'prayer_times').hijri[5:7] | int)-1] }} {{ state_attr('sensor.solat_azanpro', 'prayer_times').hijri[0:4] }}h
{%elif is_state("input_select.solat", "Local")%}{{ state_attr("sensor.solat_local", "prayerTime")[yearday-1].hijri[8:10] }} {{ months[(state_attr("sensor.solat_local", "prayerTime")[yearday-1].hijri[5:7] | int)-1] }} {{ state_attr("sensor.solat_local", "prayerTime")[yearday-1].hijri[0:4] }}h
{%endif%}
attribute_templates:
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
## Solat API ##
- platform: rest
name: solat_local
resource_template: "{{states('input_text.homeurl')}}/local/esolat.json"
json_attributes:
- zone
- prayerTime
- serverTime
value_template: '{{ value_json.zone }}'
- platform: rest
name: solat_azanpro
scan_interval: 7200
resource_template: "https://api.azanpro.com/times/today.json?zone={{states('input_text.solat')}}&format=24-hour"
json_attributes:
- zone
- prayer_times
value_template: >-
{% if value_json is defined %}{{ value_json.zone }}
{% else %}Offline
{% endif %}
- platform: rest
name: solat_jakim
scan_interval: 7200
resource_template: "https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period=today&zone={{states('input_text.solat')}}"
json_attributes:
- zone
- prayerTime
value_template: >-
{% if value_json is defined %}{{ value_json.zone }}
{% else %}Offline
{% endif %}
- platform: template
sensors:
solat_imsak:
friendly_name: "Imsak"
icon_template: mdi:star-crescent
value_template: >-
{%if is_state("input_select.solat", "eSolat")%}{{as_timestamp(now().date() ~ " " ~ state_attr('sensor.solat_jakim', 'prayerTime')[0].imsak) | timestamp_custom("%I:%M %p", true)}}
{%elif is_state("input_select.solat", "AzanPro")%}{%if as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["imsak"], "%H:%M") | timestamp_custom("%I:%M %p", true) == "%H:%M"%}Unavailable{%else%}{{as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["imsak"], "%H:%M") | timestamp_custom("%I:%M %p", true)}}{%endif%}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].imsak, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}
{%endif%}
attribute_templates:
24hours: >-
{%if is_state("input_select.solat", "eSolat")%}{{strptime(state_attr('sensor.solat_jakim', 'prayerTime')[0].imsak[0:5],'%I:%M %p')}}
{%elif is_state("input_select.solat", "AzanPro")%}{{state_attr("sensor.solat_azanpro", "prayer_times")["imsak"]}}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].imsak, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
solat_subuh:
friendly_name: "Subuh"
icon_template: mdi:star-crescent
value_template: >-
{%if is_state("input_select.solat", "eSolat")%}{{as_timestamp(now().date() ~ " " ~ state_attr('sensor.solat_jakim', 'prayerTime')[0].fajr) | timestamp_custom("%I:%M %p", true)}}
{%elif is_state("input_select.solat", "AzanPro")%}{%if as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["subuh"], "%H:%M") | timestamp_custom("%I:%M %p", true) == "%H:%M"%}Unavailable{%else%}{{as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["subuh"], "%H:%M") | timestamp_custom("%I:%M %p", true)}}{%endif%}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].fajr, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}
{%endif%}
attribute_templates:
24hours: >-
{%if is_state("input_select.solat", "eSolat")%}{{strptime(state_attr('sensor.solat_jakim', 'prayerTime')[0].fajr[0:5],'%I:%M %p')}}
{%elif is_state("input_select.solat", "AzanPro")%}{{state_attr("sensor.solat_azanpro", "prayer_times")["subuh"]}}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].fajr, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
solat_syuruk:
friendly_name: "Syuruk"
icon_template: mdi:star-crescent
value_template: >-
{%if is_state("input_select.solat", "eSolat")%}{{as_timestamp(now().date() ~ " " ~ state_attr('sensor.solat_jakim', 'prayerTime')[0].syuruk) | timestamp_custom("%I:%M %p", true)}}
{%elif is_state("input_select.solat", "AzanPro")%}{%if as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["syuruk"], "%H:%M") | timestamp_custom("%I:%M %p", true) == "%H:%M"%}Unavailable{%else%}{{as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["syuruk"], "%H:%M") | timestamp_custom("%I:%M %p", true)}}{%endif%}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].syuruk, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}
{%endif%}
attribute_templates:
24hours: >-
{%if is_state("input_select.solat", "eSolat")%}{{strptime(state_attr('sensor.solat_jakim', 'prayerTime')[0].syuruk[0:5],'%I:%M %p')}}
{%elif is_state("input_select.solat", "AzanPro")%}{{state_attr("sensor.solat_azanpro", "prayer_times")["syuruk"]}}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].syuruk, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
solat_zohor:
friendly_name: "Zohor"
icon_template: mdi:star-crescent
value_template: >-
{%if is_state("input_select.solat", "eSolat")%}{{as_timestamp(now().date() ~ " " ~ state_attr('sensor.solat_jakim', 'prayerTime')[0].dhuhr) | timestamp_custom("%I:%M %p", true)}}
{%elif is_state("input_select.solat", "AzanPro")%}{%if as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["zohor"], "%H:%M") | timestamp_custom("%I:%M %p", true) == "%H:%M"%}Unavailable{%else%}{{as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["zohor"], "%H:%M") | timestamp_custom("%I:%M %p", true)}}{%endif%}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].dhuhr, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}
{%endif%}
attribute_templates:
24hours: >-
{%if is_state("input_select.solat", "eSolat")%}{{strptime(state_attr('sensor.solat_jakim', 'prayerTime')[0].dhuhr[0:5],'%I:%M %p')}}
{%elif is_state("input_select.solat", "AzanPro")%}{{state_attr("sensor.solat_azanpro", "prayer_times")["zohor"]}}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].dhuhr, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
solat_asar:
friendly_name: "Asar"
icon_template: mdi:star-crescent
value_template: >-
{%if is_state("input_select.solat", "eSolat")%}{{as_timestamp(now().date() ~ " " ~ state_attr('sensor.solat_jakim', 'prayerTime')[0].asr) | timestamp_custom("%I:%M %p", true)}}
{%elif is_state("input_select.solat", "AzanPro")%}{%if as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["asar"], "%H:%M") | timestamp_custom("%I:%M %p", true) == "%H:%M"%}Unavailable{%else%}{{as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["asar"], "%H:%M") | timestamp_custom("%I:%M %p", true)}}{%endif%}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].asr, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}
{%endif%}
attribute_templates:
24hours: >-
{%if is_state("input_select.solat", "eSolat")%}{{strptime(state_attr('sensor.solat_jakim', 'prayerTime')[0].asr[0:5],'%I:%M %p')}}
{%elif is_state("input_select.solat", "AzanPro")%}{{state_attr("sensor.solat_azanpro", "prayer_times")["asar"]}}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].asr, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
solat_maghrib:
friendly_name: "Maghrib"
icon_template: mdi:star-crescent
value_template: >-
{%if is_state("input_select.solat", "eSolat")%}{{as_timestamp(now().date() ~ " " ~ state_attr('sensor.solat_jakim', 'prayerTime')[0].maghrib) | timestamp_custom("%I:%M %p", true)}}
{%elif is_state("input_select.solat", "AzanPro")%}{%if as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["maghrib"], "%H:%M") | timestamp_custom("%I:%M %p", true) == "%H:%M"%}Unavailable{%else%}{{as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["maghrib"], "%H:%M") | timestamp_custom("%I:%M %p", true)}}{%endif%}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].maghrib, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}
{%endif%}
attribute_templates:
24hours: >-
{%if is_state("input_select.solat", "eSolat")%}{{strptime(state_attr('sensor.solat_jakim', 'prayerTime')[0].maghrib[0:5],'%I:%M %p')}}
{%elif is_state("input_select.solat", "AzanPro")%}{{state_attr("sensor.solat_azanpro", "prayer_times")["maghrib"]}}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].maghrib, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
solat_isyak:
friendly_name: "Isyak"
icon_template: mdi:star-crescent
value_template: >-
{%if is_state("input_select.solat", "eSolat")%}{{as_timestamp(now().date() ~ " " ~ state_attr('sensor.solat_jakim', 'prayerTime')[0].isha) | timestamp_custom("%I:%M %p", true)}}
{%elif is_state("input_select.solat", "AzanPro")%}{%if as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["isyak"], "%H:%M") | timestamp_custom("%I:%M %p", true) == "%H:%M"%}Unavailable{%else%}{{as_timestamp(now().date() ~ " " ~ state_attr("sensor.solat_azanpro", "prayer_times")["isyak"], "%H:%M") | timestamp_custom("%I:%M %p", true)}}{%endif%}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].isha, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}
{%endif%}
attribute_templates:
24hours: >-
{%if is_state("input_select.solat", "eSolat")%}{{strptime(state_attr('sensor.solat_jakim', 'prayerTime')[0].isha[0:5],'%I:%M %p')}}
{%elif is_state("input_select.solat", "AzanPro")%}{{state_attr("sensor.solat_azanpro", "prayer_times")["isyak"]}}
{%elif is_state("input_select.solat", "Local")%}{%set yearday = now().strftime("%j") | int%}{{as_timestamp(strptime(state_attr("sensor.solat_local", "prayerTime")[yearday-1].isha, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}
solat_sekarang:
friendly_name: "Waktu Sekarang"
icon_template: mdi:star-crescent
value_template: >-
{%if now().strftime("%H:%M") >= state_attr("sensor.solat_imsak", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_subuh", "24hours")%}Imsak
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_subuh", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_syuruk", "24hours")%}Subuh
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_syuruk", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_zohor", "24hours")%}Syuruk
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_zohor", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_asar", "24hours")%}Zohor
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_asar", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_maghrib", "24hours")%}Asar
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_maghrib", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_isyak", "24hours")%}Maghrib
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_isyak", "24hours")%}Isyak
{%else%}Isyak
{%endif%}
attribute_templates:
24hours: >-
{%if now().strftime("%H:%M") >= state_attr("sensor.solat_imsak", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_subuh", "24hours")%}{{state_attr("sensor.solat_imsak", "24hours")}}
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_subuh", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_syuruk", "24hours")%}{{state_attr("sensor.solat_subuh", "24hours")}}
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_syuruk", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_zohor", "24hours")%}{{state_attr("sensor.solat_syuruk", "24hours")}}
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_zohor", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_asar", "24hours")%}{{state_attr("sensor.solat_zohor", "24hours")}}
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_asar", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_maghrib", "24hours")%}{{state_attr("sensor.solat_asar", "24hours")}}
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_maghrib", "24hours") and now().strftime("%H:%M") < state_attr("sensor.solat_isyak", "24hours")%}{{state_attr("sensor.solat_maghrib", "24hours")}}
{%elif now().strftime("%H:%M") >= state_attr("sensor.solat_isyak", "24hours")%}{{state_attr("sensor.solat_isyak", "24hours")}}
{%else%}{{state_attr("sensor.solat_isyak", "24hours")}}
{%endif%}
source: >-
{%if is_state("input_select.solat", "eSolat")%}eSolat
{%elif is_state("input_select.solat", "AzanPro")%}AzanPro
{%elif is_state("input_select.solat", "Local")%}Local
{%endif%}