I’ve been trying to get your addon to work but I’m getting unknown when I remove == states(‘sensor.time’) and always false if I dont.
If I run http://localhost:1453/api/dailyPrayerTimes/11421 I get correct results
{"regionId":11421,"region":"Melbourne","prayerTimes":[{"date":"23.03.2023","fajr":"05:58","sun":"07:18","dhuhur":"13:32","asr":"16:56","maghrib":"19:36","isha":"20:51"},{"date":"24.03.2023","fajr":"05:59","sun":"07:19","dhuhur":"13:32","asr":"16:55","maghrib":"19:34","isha":"20:49"}]}
This is what I have added in my configuration.yaml
- platform: rest
name: namaz_vakti
resource: "http://localhost:1453/api/dailyPrayerTimes/11421"
scan_interval: 25200
json_attributes_path: $.prayerTimes[0]
json_attributes:
- date
- fajr
- sun
- dhuhur
- asr
- maghrib
- isha
value_template: >
{% set now = now() %}
{% set fajr = today_at(state_attr('sensor.namaz_vakti', 'fajr')) %}
{% set sun = today_at(state_attr('sensor.namaz_vakti', 'sun')) %}
{% set dhuhur = today_at(state_attr('sensor.namaz_vakti', 'dhuhur')) %}
{% set asr = today_at(state_attr('sensor.namaz_vakti', 'asr')) %}
{% set maghrib = today_at(state_attr('sensor.namaz_vakti', 'maghrib')) %}
{% set isha = today_at(state_attr('sensor.namaz_vakti', 'isha')) %}
{% if now < fajr %}
Imsak: {{ state_attr('sensor.namaz_vakti', 'fajr') }}
{% elif now < sun %}
Gunes: {{ state_attr('sensor.namaz_vakti', 'sun') }}
{% elif now < dhuhur %}
Oglen: {{ state_attr('sensor.namaz_vakti', 'dhuhur') }}
{% elif now < asr %}
Ikindi: {{ state_attr('sensor.namaz_vakti', 'asr') }}
{% elif now < maghrib %}
Aksam: {{ state_attr('sensor.namaz_vakti', 'maghrib') }}
{% elif now < isha %}
Yatsi: {{ state_attr('sensor.namaz_vakti', 'isha') }}
{% else %}
unknown
{% endif %}
- platform: template
sensors:
diyanet_imsak_vakti:
friendly_name: "Imsak Vakti"
value_template: "{{state_attr('sensor.namaz_vakti', 'fajr') }}"
diyanet_gunes_vakti:
friendly_name: "Gunes Vakti"
value_template: "{{state_attr('sensor.namaz_vakti', 'sun') }}"
diyanet_ogle_namazi:
friendly_name: "Ogle Vakti"
value_template: "{{state_attr('sensor.namaz_vakti', 'dhuhur') }}"
diyanet_ikindi_namazi:
friendly_name: "Ikindi Vakti"
value_template: "{{state_attr('sensor.namaz_vakti', 'asr') }}"
diyanet_aksam_namazi:
friendly_name: "Aksam Vakti"
value_template: "{{state_attr('sensor.namaz_vakti', 'maghrib') }}"
diyanet_yatsi_namazi:
friendly_name: "Yatsi Vakti"
value_template: "{{state_attr('sensor.namaz_vakti', 'isha') }}"
- platform: template
sensors:
imsak_notify:
friendly_name: "İmsak Vakti Notify"
value_template: "{{state_attr('sensor.namaz_vakti', 'fajr') == states('sensor.time')}}"
gunes_notify:
friendly_name: "Güneş Vakti Notify"
value_template: "{{state_attr('sensor.namaz_vakti', 'sun') == states('sensor.time')}}"
ogle_notify:
friendly_name: "Öğle Vakti Notify"
value_template: "{{state_attr('sensor.namaz_vakti', 'dhuhur') == states('sensor.time')}}"
ikindi_notify:
friendly_name: "İkindi Vakti Notify"
value_template: "{{state_attr('sensor.namaz_vakti', 'asr') == states('sensor.time')}}"
aksam_notify:
friendly_name: "Akşam Vakti Notify"
value_template: "{{state_attr('sensor.namaz_vakti', 'maghrib') == states('sensor.time')}}"
yatsi_notify:
friendly_name: "Yatsı Vakti Notify"
value_template: "{{state_attr('sensor.namaz_vakti', 'isha') == states('sensor.time')}}"