Sensor undefined when using template

I am experiencing problems with a sensor stated as not defined when referring to it in “template”.

Any ideas, why?

The sensor is working correctly and the state can be shown in both “state” under “developer tools” and using dashboards.

{% if as_timestamp(now()) > as_timestamp(states(sensor.cheapest_dishwasher_start_time)) %}
{True}
{% else %}
{False}
{% endif %}


Wrap the sensor’s entity_id in quotes

{% if as_timestamp(now()) > as_timestamp(states('sensor.cheapest_dishwasher_start_time')) %}
{{True}}
{% else %}
{{False}}
{% endif %}

If you’re interested, you can reduce the template to this:

{{ now().timestamp() > as_timestamp(states('sensor.cheapest_dishwasher_start_time')) }}

Of course - thanks.
Everything works fine now.

The optimization is also correct.