Stuck on a sensor value_template - works in the Template Editor but not "live"

I’ve spent a couple of hours on this and am really, really stuck. It is probably something stupidly simple but I’d love a bit of help.

I created a new sensor for use in computing the run time for my pool pump based on the outdoor temperature, which comes from an MQTT subscription.

sensor:
  - platform: mqtt
    state_topic: "weather/outTemp_F"
    name: Outdoor Temperature
    unit_of_measurement: '°F'

  - platform: template
    sensors:
      pool_pump_run_time:
      entity_id: sensor.pool_pump_run_time
      friendly_name: "Pool Pump Run Time"
      unit_of_measurement: 'minutes'
      value_template: >-
        {% if states.sensor.outdoor_temperature.state|int - 75 > 0 %}
        {{ (states.sensor.outdoor_temperature.state|int - 75) * 6 }}
        {% else %}
        0
        {% endif %}

The value of sensor.outdoor_temperature is shown correctly in the states panel as 80.

When I edit the value_template in the Template Editor it works fine and displays the correct number (80 - 75) * 6 = 30. BUT the value of sensor.pool_pump_run_time is always zero in the states panel.

If I put a constant (e.g., 80) in place of states.sensor.outdoor_temperature.state the calculation is done correctly and the result is displayed in the states panel. I’ve tried every variation of the outdoor_temperature sensor name - e.g., states (‘sensor.outdoor_temperature’) - to no avail.

Any suggestions from those of you with more experience at this than me?

Check the entity_id you’ve specified in the Template Sensor.

It should be sensor.outdoor_temperature because that’s what you’re using in value_template. You’ve used sensor.pool_pump_run_time which is the Template Sensor’s own entity_id.

I knew it was something stupidly simple! Thanks so much, it works a treat now.

  pool_pump_run_time:
    entity_id: sensor.outdoor_temperature
    friendly_name: "Pool Pump Run Time"
    unit_of_measurement: 'minutes'
    value_template: >-
      {% if states.sensor.outdoor_temperature.state|int - 60 > 0 %}
      {{ (states.sensor.outdoor_temperature.state|int - 60) * 6 }}
      {% else %}
      0
      {% endif %}