I’m using the afvalinfo integration which currently gives me 6x sensors:
- 4x sensor.afvalinfo_home_xxxx which basically shows the date that these types of trash items will be collected, as well as some extra attributes including days_until_collection_date
- 2x sensors (trash_type_today / trash_type_tomorrow) which give the trash type being collected either today or tomorrow.
Right, then I have this template below which creates a sensor to show the next trash type (in general) which will be collected.
However, what I’m actually looking for is the next item…. but excluding today and tomorrow.
{% set ns = namespace(minimum=365) %}
{% set list = ['gft', 'pbd', 'papier', 'restafval'] %}
{%- for l in list %}
{%- set days = state_attr('sensor.afvalinfo_home_' ~l, 'days_until_collection_date')%}
{%- if days != None and days < ns.minimum %}
{%- set ns.minimum = days %}
{%- endif %}
{%- endfor %}
{%- for l in list %}
{%- set days = state_attr('sensor.afvalinfo_home_' ~l, 'days_until_collection_date')%}
{%- if days == ns.minimum %}
{{ list[loop.index0] }}
{%- endif %}
{%- endfor %}