Binary_sensor not returning the correct state

there is probably something really silly but I can’t see what it is.
I created a binary_sensor to track the status of a currentcost energy monitor, the idea is that if it doesn’t get updated for at least 5 min, something is wrong (the sensors itself refreshes every 5 sec)
My binary_sensor code is:

- platform: template
  sensors:
    currentcost_lost:
      entity_id:
        - sensor.currentcost_power
      value_template: >
        {% if (as_timestamp(now()) - as_timestamp(states.sensor.currentcost_power.last_updated) | int > 500 ) %}on{% else %}off{% endif %}
      friendly_name: CurrentCost Lost

now when I check my code in the templates, {% if (as_timestamp(now()) - as_timestamp(states.sensor.currentcost_power.last_updated) | int > 500 ) %}on{% else %}off{% endif %} returns on, yet {{states.binary_sensor.currentcost_lost.state}} returns off

Any idea why?