Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## JAKIM eSolat (experimental) ##
- # Based on json response stored into a file.
- # Place the json file into config/www/
- ## configuration.yaml ##
- sensor:
- - platform: rest
- name: eSolat API
- resource: https://xxx.duckdns.org/local/esolat.json
- json_attributes:
- - zone
- - prayerTime
- - serverTime
- value_template: '{{ value_json.zone }}'
- - platform: template
- sensors:
- esolat_hijri:
- friendly_name: "eSolat Hijri Date"
- icon_template: mdi:calendar
- value_template: >-
- {% set yearday = now().strftime("%j") | int %}
- {{ states.sensor.esolat_api.attributes.prayerTime[yearday-1].hijri }}
- esolat_hijri_full:
- friendly_name: "eSolat Hijri Date Full"
- icon_template: mdi:calendar
- value_template: >-
- {% set months = ['Muharram', 'Safar', 'Rabi\'ul Awwal', 'Rabi\'ul Akhir', 'Jamadil Awwal', 'Jamadil Akhir', 'Rejab', 'Sha\'aban', 'Ramadhan', 'Syawwal', 'Zulkaedah', 'Zulhijjah'] %}
- {% set yearday = now().strftime("%j") | int %}
- {{ states.sensor.esolat_api.attributes.prayerTime[yearday-1].hijri[8:10] }} {{ months[(states.sensor.esolat_api.attributes.prayerTime[yearday-1].hijri[5:7] | int)-1] }} {{ states.sensor.esolat_api.attributes.prayerTime[yearday-1].hijri[0:4] }}h
- esolat_imsak:
- friendly_name: 'Imsak'
- icon_template: mdi:islam
- value_template: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].imsak, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}'
- attribute_templates:
- 24hours: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].imsak, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}'
- esolat_subuh:
- friendly_name: 'Subuh'
- icon_template: mdi:islam
- value_template: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].fajr, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}'
- attribute_templates:
- 24hours: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].fajr, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}'
- esolat_syuruk:
- friendly_name: 'Syuruk'
- icon_template: mdi:islam
- value_template: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].syuruk, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}'
- attribute_templates:
- 24hours: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].syuruk, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}'
- esolat_zohor:
- friendly_name: 'Zohor'
- icon_template: mdi:islam
- value_template: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].dhuhr, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}'
- attribute_templates:
- 24hours: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].dhuhr, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}'
- esolat_asar:
- friendly_name: 'Asar'
- icon_template: mdi:islam
- value_template: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].asr, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}'
- attribute_templates:
- 24hours: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].asr, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}'
- esolat_maghrib:
- friendly_name: 'Maghrib'
- icon_template: mdi:islam
- value_template: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].maghrib, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}'
- attribute_templates:
- 24hours: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].maghrib, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}'
- esolat_isyak:
- friendly_name: 'Isyak'
- icon_template: mdi:islam
- value_template: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].isha, "%H:%M:%S")) | timestamp_custom("%I:%M %p", true)}}'
- attribute_templates:
- 24hours: '{% set yearday = now().strftime("%j") | int %}{{as_timestamp(strptime(states.sensor.esolat_api.attributes.prayerTime[yearday-1].isha, "%H:%M:%S")) | timestamp_custom("%H:%M", true)}}'
- esolat_waktusekarang:
- friendly_name: Waktu Sekarang
- icon_template: mdi:islam
- value_template: >-
- {% if states("sensor.time") >= state_attr("sensor.esolat_imsak", "24hours") and states("sensor.time") < state_attr("sensor.esolat_subuh", "24hours") %}
- Imsak
- {% elif states("sensor.time") >= state_attr("sensor.esolat_subuh", "24hours") and states("sensor.time") < state_attr("sensor.esolat_syuruk", "24hours") %}
- Subuh
- {% elif states("sensor.time") >= state_attr("sensor.esolat_syuruk", "24hours") and states("sensor.time") < state_attr("sensor.esolat_zohor", "24hours") %}
- Syuruk
- {% elif states("sensor.time") >= state_attr("sensor.esolat_zohor", "24hours") and states("sensor.time") < state_attr("sensor.esolat_asar", "24hours") %}
- Zohor
- {% elif states("sensor.time") >= state_attr("sensor.esolat_asar", "24hours") and states("sensor.time") < state_attr("sensor.esolat_maghrib", "24hours") %}
- Asar
- {% elif states("sensor.time") >= state_attr("sensor.esolat_maghrib", "24hours") and states("sensor.time") < state_attr("sensor.esolat_isyak", "24hours") %}
- Maghrib
- {% elif states("sensor.time") >= state_attr("sensor.esolat_isyak", "24hours") %}
- Isyak
- {%- else %}
- Isyak
- {%- endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement