Comparison of several sensors which has the smallest value

i am currently trying to make the garbage collection display a little more like i want it to be.
So I wrote this sensor. This sensor compares the garbage sensors and should give me the sensor name with the smallest value. But I only get the value unavailable. The sensors themselves have a value of “in XXX days” where XXX is the number of days.

  - platform: template
        unique_id: next_muell
        friendly_name: "Welcher Müll wird abgeholt"
        value_template: >-
          {% set sensor_names = ['sensor.abfall_gelbersack', 'sensor.abfall_papier', 'sensor.abfall_restmuell', 'sensor.abfall_bio'] %}
          {% set sensor_values = namespace(min_value=None, min_name=None) %}
          {% for sensor in sensor_names %}
            {% set sensor_value = states('sensor.' ~ sensor) | int %}
            {% if sensor_values.min_value is none or sensor_value < sensor_values.min_value %}
              {% set sensor_values.min_value = sensor_value %}
              {% set sensor_values.min_name = sensor %}
            {% endif %}
          {% endfor %}
          {{ state_attr(sensor_values.min_name, 'friendly_name') }}

I am also relatively new to the subject and therefore perhaps just do not know everything yet. Can someone please help me where the error lies and how I can eliminate it

Please show the output in the template editor for this:

{{ states('sensor.abfall_gelbersack') }}
{{ states('sensor.abfall_papier') }}

Literally “in XXX days”, timestamps with device_class: timestamp or text in German? Any other possible values?

Do you have equivalents with dates in? Like mine:

I’ve just had a go with my timestamp sensors:

If these are timestamp sensors, you could probably use something like:

{{ states.sensor
   |map(attribute='name')|first }}

Try this:

{% set sensor_value = states(sensor) | int %}

Or maybe you should also be prepared for some sensor on unknown state:

{% set sensor_value = states(sensor) | int(999) %}