Using 'split' on string with quotation marks breaks functionality

I have a timer, and I want to update it only if the new value is less than the existing one.
So first I check if the timer is idle and if so I return ‘true’ for the condition
Else, I calculate the end time of the timer using its ‘last changed’ + duration and compare it to the new value I got.
However, as I try to get the duration in seconds, I have to use the ‘split’ function which must use quotation marks, and I think it breaks the condition since it never returns true although I’ve tested its correctness with the template validator on HA
Here is the condition :

condition:
  - condition: template
    value_template: >
      {% if is_state('timer.time_to_next_alarm', 'idle') %}
        true
      {% else %}
        '{% set duration = states.timer.time_to_next_alarm.attributes.duration.split(":") %}'
        '{% set duration_sec = ((duration[0] | int) * 3600) + ((duration[1] | int) * 60) + (duration[2] | int) %}'
        '{% set end_time_unix = (as_timestamp(states.timer.time_to_next_alarm.last_changed) | round) + duration_sec %}'
         '{{ (trigger.event.data.timestamp_unix | int) }} < {{ end_time_unix }}'
      {% endif %} 

I tried like 20 different syntax with quotations and without (over whole lines), I’ve also tried moving all the variables set before the ‘if’ but that breaks the if as well.