UndefinedError: 'value' is undefined?

Hi everyone,
I get the following error message in HA.
Can you help me please?
Thanks.

sensor:
  - platform: waste_collection_schedule
    name: Abfall Restmüll
    details_format: "upcoming"
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
      - Restabfall

The Template developer tool is to debug templates, not full integration yaml.

Whatever you’re trying to test only “{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}” is meant to work there.

Even if I only use the value template I get the same error.

And also I have the following message in the log file.

Logger: homeassistant.helpers.template
Source: helpers/template.py:1254
First occurred: 8:31:18 AM (6 occurrences)
Last logged: 8:31:19 AM

Template warning: ‘int’ got invalid input ‘unknown’ when rendering template ‘{% set days = states(‘sensor.erinnerung_wasserfilter’) | int %} {% if days == 0 %} heute {% elif days == 1 %} morgen {% else %} in {{ days }} Tagen {% endif %}’ but no default was specified. Currently ‘int’ will return ‘0’, however this template will fail to render in Home Assistant core 2022.1Template warning: ‘int’ got invalid input ‘unknown’ when rendering template ‘{% set days = states(‘sensor.erinnerung_frontline’) | int %} {% if days == 0 %} heute {% elif days == 1 %} morgen {% else %} in {{ days }} Tagen {% endif %}’ but no default was specified. Currently ‘int’ will return ‘0’, however this template will fail to render in Home Assistant core 2022.1Template warning: ‘as_timestamp’ got invalid input ‘unknown’ when rendering template ‘{{ as_timestamp(states(‘sensor.samba_backup_last_backup’)) | timestamp_custom(’%d.%m.%Y - %H:%M’) }}’ but no default was specified. Currently ‘as_timestamp’ will return ‘None’, however this template will fail to render in Home Assistant core 2022.1Template warning: ‘timestamp_custom’ got invalid input ‘None’ when rendering template ‘{{ as_timestamp(states(‘sensor.samba_backup_last_backup’)) | timestamp_custom(’%d.%m.%Y - %H:%M’) }}’ but no default was specified. Currently ‘timestamp_custom’ will return ‘None’, however this template will fail to render in Home Assistant core 2022.1

This will also produce an error in the Template Editor:

{{ x + 1 }}

Why? Because the variable named x is undefined.

In your template, the variable named value is undefined. It will be defined only when the template is used in an operational Template Sensor. In your case, value will contain the data received by sensor.abfall_restmull via the Waste Collection Schedule integration.

The warning message you received is due to this:

all right, thank you.
And how can I solve the problem?
Unfortunately, I’m not really fit in programming

Solve which problem?

The error message is due to your misunderstanding of how the Template Editor works. It’s “solved” by not using it the way you did.

The warning message is due to what is described in linked post; several functions now require that you provide default values. For example, replace int with int(0) in order to make its default value 0. Refer to the linked post for a more detailed explanation.