Comparing two sensors, output values from smallest, display in Lovelace UI

Thank you for all your help! I’ll give that a try! For now I got to help calm down my 1.5 month old… :slight_smile:

So a template sensor with this as the value_template:

{% set list = [7,8,12] %} # replace this with your list of sensors
{% set i =   list.index(list |min) %}
{% set days = {"Monday": "Montag", "Tuesday": "Dienstag", "Wednesday":"Mittwoch", "Thursday": "Donnerstag", "Friday":"Freitag", "Saturday": "Samstag", "Sunday":"Sonntag" } %}

Die nächste Abholung ist der <b>{{  [ "Hausmüll", "Biogut", "Wertstofftonne"][i] }}</b>, am <b>{{ days[as_timestamp(now() + timedelta(days=list|min)) | timestamp_custom("%A")] }}</b>, den {{ as_timestamp(now() + timedelta(days=list|min)) | timestamp_custom("%d. %b. %Y") | replace("Mar", "Mrz") | replace("May", "Mai") |replace("Oct", "Okt") | replace("Dec", "Dez") ~ " (in " ~ list |min ~ " Tagen)" }}

This outputs:

( note that the order of the “sensors” are not the same as yours, that is why I get Hausmüll)

1 Like

Omg thank you!

I’ll give this a try hopefully tomorrow and will report back.

Thanks again for your help! Very much appreciated!

Here is another approach.

its a bit longer but I tested it with the current sensors exactly with the data I have for the address you gave me and it seems to be working correctly.

feel free to try it out:

{% set date_1 = states.sensor.abfallnaechster.attributes | first | as_timestamp %}
{% set date_2 = states.sensor.biomuell.attributes | first | as_timestamp %}
{% set date_3 = states.sensor.restmuell.attributes | first | as_timestamp %}
{% set date_4 = states.sensor.wertstoff.attributes | first | as_timestamp %}

{% set entity_1 = "sensor.abfallnaechster" %}
{% set entity_2 = "sensor.biomuell" %}
{% set entity_3 = "sensor.restmuell" %}
{% set entity_4 = "sensor.wertstoff" %}

{% set type_1 = states.sensor.abfallnaechster.attributes.values() | first %}
{% set type_2 = states.sensor.biomuell.attributes.values() | first %}
{% set type_3 = states.sensor.restmuell.attributes.values() | first %}
{% set type_4 = states.sensor.wertstoff.attributes.values() | first %}

{% set dict_1 = date_1,type_1 %}
{% set dict_2 = date_2,type_2 %}
{% set dict_3 = date_3,type_3 %}
{% set dict_4 = date_4,type_4 %}

{% set dict_11 = date_1,entity_1 %}
{% set dict_12 = date_2,entity_2 %}
{% set dict_13 = date_3,entity_3 %}
{% set dict_14 = date_4,entity_4 %}

{% set type =  ([dict_1, dict_2, dict_3, dict_4] | min)[1] %}
{% set date = (([dict_11, dict_12, dict_13, dict_14] | min)[0]) %}
{% set entity = ([dict_11, dict_12, dict_13, dict_14] | min)[1] %}

{{type |
          replace("Hausabfall", "Restmüll") | replace("Biomuell", "Biomüll") |
          replace("Biogut", "Biomüll") }}</b>, am <b>
{{date |
          timestamp_custom("%A</b>, den %d. %b. %Y") | replace("Monday",
          "Montag") | replace("Tuesday", "Dienstag") | replace("Wednesday",
          "Mittwoch") | replace("Thursday", "Donnerstag") | replace("Friday",
          "Freitag") | replace("Saturday", "Samstag") | replace("Sunday",
          "Sonntag") | replace("Mar", "Mrz") | replace("May", "Mai") |
          replace("Oct", "Okt") | replace("Dec", "Dez") }} 
({{  states(entity)}}).
1 Like