How to format condition

I am using a condition to get some information about the weather and a forecast but recently it started showing an error.

This is what I’ve added to configuration.yaml a long time ago:
```

{{as_timestamp(strptime(state_attr(‘weather.smhi_home’,
‘forecast’)[2].datetime, ‘%Y-%m-%d %H:%M:%S’)) |
timestamp_custom("%a %-d") }}
<ha-icon
icon={{states(‘sensor.weather_smhi_icon2’)}}>

{{state_attr(‘weather.smhi_home’,
‘forecast’)[2].temperature}} /
{{state_attr(‘weather.smhi_home’,
‘forecast’)[2].templow}}


I did that some years ago and I think that what I want is the day (like Sat) and the day number of the month (like 29)

Here is the error message:

2022-04-29 13:08:45 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'strptime' got invalid input '2022-05-04T12:00:00' when rendering template '<center> {{as_timestamp(strptime(state_attr('weather.smhi_home', 'forecast')[5].datetime, '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%a %-d") }}</BR> <ha-icon icon={{states('sensor.weather_smhi_icon5')}}></ha-icon></br> {{state_attr('weather.smhi_home', 'forecast')[5].temperature}} / {{state_attr('weather.smhi_home', 'forecast')[5].templow}}  </center>' but no default was specified. Currently 'strptime' will return '2022-05-04T12:00:00', however this template will fail to render in Home Assistant core 2022.1

The reason for the warning message is explained within the warning message itself. Your template is using the strptime() function without specifying a default value.

Template warning: ‘strptime’ got invalid input … no default was specified

This requirement (need to supply a default value) was implemented last fall. Here’s a useful post explaining it, which functions/filters are affected, and what you need to do to comply with it.

Thank you @123 !

I am trying to understand this and added a zero (0) but now instead of days I always get returned 0.

                  <center>
                  {{as_timestamp(strptime(state_attr('weather.smhi_home',
                  'forecast')[1].datetime, '%Y-%m-%d %H:%M:%S', 0)) |
                  timestamp_custom("%a %-d") }}</BR> <ha-icon
                  icon={{states('sensor.weather_smhi_icon1')}}></ha-icon></br>
                  {{state_attr('weather.smhi_home',
                  'forecast')[1].temperature}} /
                  {{state_attr('weather.smhi_home',
                  'forecast')[1].templow}}  </center>

Confirm the data referenced by the state_attr() function is in the format that you have configured strptime() to convert.

Now I get the right value returned again (I added “, 0” as a test at the end of the first line) but as I dont understand the coding I still get the same error message:
got invalid input
but no default was specified. Currently ‘strptime’ will return ‘2022-05-03T12:00:00’, however this template will fail to render in Home Assistant core 2022.1

                      {{as_timestamp(strptime(state_attr('weather.smhi_home',
                      'forecast')[1].datetime, '%Y-%m-%d %H:%M:%S'), 0) |
                      timestamp_custom("%a %-d") }}</BR> <ha-icon
                      icon={{states('sensor.weather_smhi_icon1')}}></ha-icon></br>
                      {{state_attr('weather.smhi_home',
                      'forecast')[1].temperature}} /
                      {{state_attr('weather.smhi_home',
                      'forecast')[1].templow}}  </center>

Is there some easier way to do this or am I just missing some formatting in that code? I’ve understood that I need a default value but I haven’t figured out a working way for it.