Help with template in script

Hey everyone I’m trying to put a template in a script I have. So I want to turn on a fan if the Nest’s current temp is over 72 degrees and otherwise just let is off.

Here is what I have but it doesn’t seem to work:

{% if states('climate.nest.current_temperature') | int > 72 %}
  - service: switch.turn_on
    entity_id: switch.living_room_fan
{%endif %}

So I have this in the middle of one of my scripts. Thanks for any help!!

Okay looks like this worked:

  - service_template: > 
      {% if states.climate.nest.attributes.current_temperature | int > 72 %}
      {% endif %}
    entity_id: switch.living_room_fan