since the template was posted here, this is for now a placeholder in migration to 2021.10 + given the templating changes that were made on the default values one templates. This:
{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %}
{% set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %}
{%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %}
{%- set wday = tracker_timestamp|timestamp_custom('%w')|int %}
{%- set month = tracker_timestamp |timestamp_custom('%m')|int %}
{{tracker_timestamp|timestamp_custom(wdays[wday] ~ ' ' '%-d' ' ' ~ months[month-1])}}
results in 3 errors (repeating)
2021-10-12 00:53:36 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'strptime' got invalid input 'Geen' when rendering template '{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %} {% set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %} {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %} {%- set wday = tracker_timestamp|timestamp_custom('%w')|int %} {%- set month = tracker_timestamp |timestamp_custom('%m')|int %} {{tracker_timestamp|timestamp_custom(wdays[wday] ~ ' ' '%-d' ' ' ~ months[month-1])}}' but no default was specified. Currently 'strptime' will return 'Geen', however this template will fail to render in Home Assistant core 2021.12
2021-10-12 00:53:36 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'as_timestamp' got invalid input 'Geen' when rendering template '{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %} {% set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %} {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %} {%- set wday = tracker_timestamp|timestamp_custom('%w')|int %} {%- set month = tracker_timestamp |timestamp_custom('%m')|int %} {{tracker_timestamp|timestamp_custom(wdays[wday] ~ ' ' '%-d' ' ' ~ months[month-1])}}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2021.12
2021-10-12 00:53:36 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input 'None' when rendering template '{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %} {% set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %} {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %} {%- set wday = tracker_timestamp|timestamp_custom('%w')|int %} {%- set month = tracker_timestamp |timestamp_custom('%m')|int %} {{tracker_timestamp|timestamp_custom(wdays[wday] ~ ' ' '%-d' ' ' ~ months[month-1])}}' but no default was specified. Currently 'timestamp_custom' will return 'None', however this template will fail to render in Home Assistant core 2021.12
i have posted it also in a dedicated thread on the templating changes for some help, but thought a repost here might be a good idea.
Not sure if simply defaulting any of these should be the solution, maybe we need the entities which are used in this template, specifically the sensor.afvalwijzer_next_date to have another state than Geen…
to be continued
this should be it:
- unique_id: volgende_afval_ophaal_dag
name: Volgende afval-ophaal dag
state: >
{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y',none),none) %}
{% set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %}
{%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %}
{%- set wday = tracker_timestamp|timestamp_custom('%w',default=none)|int %}
{%- set month = tracker_timestamp |timestamp_custom('%m',default=none)|int %}
{{tracker_timestamp|timestamp_custom(wdays[wday] ~ ' ' '%-d' ' ' ~ months[month-1],default=none)}}