Hi, I’ve been trying to turn these entities into timestamp entities for the last 8 hours so I can use them in the time automation to play audio when each entities time is reached. but haven’t had any luck.
Please help
rest:
method: GET
scan_interval: 172800
resource: "https://ezanvakti.herokuapp.com/vakitler/13978"
sensor:
- name: Imsak
value_template: >-
{% for entry in value_json %} {% if entry.MiladiTarihKisa ==
now().strftime('%d.%m.%Y') %} {{ entry.Imsak }} {% endif %} {% endfor %}
- name: Ogle
value_template: >-
{% for entry in value_json %} {% if entry.MiladiTarihKisa ==
now().strftime('%d.%m.%Y') %} {{ entry.Ogle }} {% endif %} {% endfor %}
- name: Ikindi
value_template: >-
{% for entry in value_json %} {% if entry.MiladiTarihKisa ==
now().strftime('%d.%m.%Y') %} {{ entry.Ikindi }} {% endif %} {% endfor
%}
- name: Aksam
value_template: >-
{% for entry in value_json %} {% if entry.MiladiTarihKisa ==
now().strftime('%d.%m.%Y') %} {{ entry.Aksam }} {% endif %} {% endfor %}
- name: Yatsi
value_template: >-
{% for entry in value_json %} {% if entry.MiladiTarihKisa ==
now().strftime('%d.%m.%Y') %} {{ entry.Yatsi }} {% endif %} {% endfor %}
- name: hicri
value_template: >-
{% for entry in value_json %} {% if entry.MiladiTarihKisa ==
now().strftime('%d.%m.%Y') %} {{ entry.HicriTarihUzun }} {% endif %} {%
endfor %}
- name: Gunes
value_template: >-
{% for entry in value_json %} {% if entry.MiladiTarihKisa ==
now().strftime('%d.%m.%Y') %} {{ entry.Gunes }} {% endif %} {% endfor %}
Perfect, thank you so much this was killing me not being able to work this out. I even tried chatgp without success lol
How would I make sensors that show true when the time is at the same time as these entities?
Also what is the code you have on the top in developer tools?
Lots of ways. I’d do it like this, once you’ve installed sensor.time as described here:
template:
- binary_sensor:
- name: Imsak is now
state: "{{ as_datetime(states('sensor.imsak')).strftime('%H:%M') == states('sensor.time') }}"
The {% set value_json...? That is a copy-paste of the response from your URL, in effect, pretending to be the rest sensor in order to prove out & demonstrate the template below.
Legend!
One last thing, in my dashboard I want to add them in a horizontal stack with the glance card but it is showing time remaining rather than the times. How do I get it to show the times rather than the time remaining?
Update
All good, figured it out. Just added format: time to the card under entity:
Thanks again for the fast solutions!
@Troon hey this seems to only have worked the first day I did it. I did some home assistant updates that were pending either that day or the day after which may have effected it. Any idea why it worked the first day only? All the automations are showing last run 3 days ago.