Hi, confused about this.
I use this template in the developer call service dev box, and it correctly adjusts the corresponding input_text to the next 30 min period, if the current value is in the past. But when run as an action in an automation, the result is a blank value:
service: input_text.set_value
data:
value: |
{% if now() > today_at(states('input_text.octopus_incoming_target_from')) %}
{% if now().minute > 30 %}
{{ (now()+timedelta(hours = 1)).strftime("%H") }}:00
{% else %}
{{ now().strftime("%H") }}:30
{%endif %}
{%endif %}
target:
entity_id: input_text.octopus_incoming_target_from
However, if I use “folded style” yaml in the automation:
service: input_text.set_value
data:
value: >
{% if now() > today_at(states('input_text.octopus_incoming_target_from')) %}
{% if now().minute > 30 %}
{{ (now()+timedelta(hours = 1)).strftime("%H") }}:00
{% else %}
{{ now().strftime("%H") }}:30
{%endif %}
{%endif %}
target:
entity_id: input_text.octopus_incoming_target_from
its fine in the automation context, but in the developer ‘call-state’ service dev tool, same code ends up leaving a blank value!
So it appears the same yaml is not being interpreted quite the same way from the UI, which wasn’t at all obvious to me. And its not helpful that there seemed to be no error message, so it silently ignored my template until I happened to hit on the fact it was the | vs > causing the problem. What am I missing?
Thanks