Getting invalid data when using data_template

Hi

I have spend the 6 hours and am at a loss as to how to fix this problem. I googled and tried every thing I’ve found. You guys are my last hope.

Here is the error message:

Error while executing automation automation.ifttt_starts_the_timer. Invalid data for call_service at pos 2: offset “00:02:00” should be format ‘HH:MM’ or ‘HH:MM:SS’ for dictionary value @ data[‘duration’]

The following is my automation code:

- id: start_timer_for_iftt_events
  alias: IFTTT starts the timer
  trigger:
    platform: event
    event_type: ifttt_webhook_received
    event_data:
      action: start_timer
  action:
    - service: timer.start
      data_template:
        duration: > 
          {% set temp = 16 %}
          {% if temp > 25 %}
            "00:01:00"
          {% elif  temp > 15%}
            "00:02:00"
          {% elif  temp > 8%}
            "00:03:00"
          {% else %}
            "00:04:00"
          {% endif %}
        entity_id: '{{ trigger.event.data.entity_id }}'

Regards,

Try it without the quotes:

  action:
    - service: timer.start
      data_template:
        duration: > 
          {% set temp = 16 %}
          {% if temp > 25 %}
            00:01:00
          {% elif  temp > 15 %}
            00:02:00
          {% elif  temp > 8 %}
            00:03:00
          {% else %}
            00:04:00
          {% endif %}
        entity_id: '{{ trigger.event.data.entity_id }}'

Also I assume this:

          {% set temp = 16 %}

is just for testing?

Hi Tom

Your advice works. You rock!

Yes, {% set temp = 16 %} is only for testing. The actual code is more involved.

Thank you.

No worries. For your reference, quotes are not required when using multi-line templates.