Read Attribute from Sensor based based on next Date

Hi Everyone,
I’m new to HA and using Waste Collection Schedule. This creates a sensor with multiple attributes.
Its a list of dates which kind of trash will be collected on this date.
As i’m from Germany and we love to seperate any kind of waste, there a a lot of different waste bins.

I try to write a notification which includes the next attribute with the next upcoming date.
For example i’d like to use “Biomüll” in the notification, because the 18th of Dec. is the next date.

Is this possible?

Since the state of the sensor seems to be the number of days until the next collection date, you can use that to determine the key for the first attribute.

{% set target_date = (today_at() + 
timedelta(days=states('sensor.wastemgmt_naechsteabholung') | int)).date()|string %} 
{{ state_attr('sensor.wastemgmt_naechsteabholung', target_date) }}

Templating Documentation

1 Like

Oh, perfect. I really have to go deeper into this.