Error in a date template

Hi
I don’t understand why it throwing an error while the template works? Am I missing something?

Template (because I’m only looking after the date, not the timestamp):
{{ states('sensor.strava_0_0') | as_timestamp | timestamp_custom('%Y-%m-%d') }}

the sensor that the template uses:
image

but I’ve got errors like this:
homeassistant.exceptions.TemplateError: ValueError: Template error: as_timestamp got invalid input 'unavailable' when rendering template '{{ states('sensor.strava_0_0') | as_timestamp | timestamp_custom('%Y-%m-%d') }}' but no default was specified

the way the template is setup is correct right?

At some point The strava sensor was unavailable. That is when the error was generated. You need to supply a default value for your as_timestamp filter to prevent this happening.

you mean adding a default like this?
{{ states('sensor.strava_0_0') | as_timestamp(default) | timestamp_custom('%Y-%m-%d') }}

or like this?
{{ states('sensor.strava_0_0') | as_timestamp | timestamp_custom('%Y-%m-%d', 0) }}

hmm this one also works (not sure if it solves the issue though but in the template tester it is OK)
{{ states('sensor.strava_0_0') | as_timestamp(default) | timestamp_custom('%Y-%m-%d', 0) }}

but to be honest I don’t know the actual difference between them and which one to use.

See: Updating Templates with the new default values in 2021.10.x

e.g. If you want now as the default:

{{ states('sensor.strava_0_0') | as_timestamp(now()) | timestamp_custom('%Y-%m-%d') }}

hm I’m using your example, are you sure that we don’t need a (default) or ,0 somewhere in the template?

homeassistant.exceptions.TemplateError: ValueError: Template error: timestamp_custom got invalid input '2024-08-16 10:05:56.365599+02:00' when rendering template '{{ states('sensor.strava_0_0') | as_timestamp(now()) | timestamp_custom('%Y-%m-%d') }}' but no default was specified