Automation with "timer"

Hi,
I have written this automation in the past and it work just fine. But recently I changed to the newest version of Home Assistant and it is not working any more.

  - alias: vent_timer
    trigger:
    - platform: state
      entity_id: switch.ventilator_ventilator
      to: 'on'
      for:
        minutes: "{{ states('input_number.vent_time')|int }}"
    action:
      - entity_id: switch.ventilator_ventilator
        service_template: >
            {% if states('input_number.vent_time')|int > 0 %}
              switch.turn_off
            {% else %}
              switch.turn_on
            {% endif %} 

It is supposed to turn the Ventilator off after the minutes (configured with the input_number) have passed.

You really don’t need the service template for that:

  - alias: vent_timer
    trigger:
    - platform: state
      entity_id: switch.ventilator_ventilator
      to: 'on'
      for:
        minutes: "{{ states('input_number.vent_time')|int }}"
    action:
    - service: switch.turn_off
      entity_id: switch.ventilator_ventilator

Edit: oh you left out some important information that was in your other topic:

So you do need the service template.

Oh yes,
I totally forgot to write this in the new topic. Sorry