Trash notification showing date instead of type

I set up an automation to get a notification on my phone the day before the trash will be emptied.

It works mostly as intended, but:

“Tomorrow the “08.04.2025” will be emptied!” is pointless.

For the notification I use:

action: notify.mobile_app_myphone
data_template:
  title: Trash
  message: >-
    Tomorrow the {{
    (states.sensor.trash.attributes.values()|list)[0] }} will be emptied!

The entity “sensor.trash” has the following state:

Paper: "2025-04-08"
Plastic: "2025-04-11"
Organic: "2025-04-16"
attribution: "Last update: 04/07/25 13:20:39"
icon: fas:trash
friendly_name: Trash

Apparently I need to fix states.sensor.trash.attributes.values()|list)[0], but I didn’t manage to find out how!
Can someone point me in the right direction?

Change values() to keys()

1 Like

Thanks! That solved the problem!
PS: Do you know of any guide where such things are explained? Haven’t found any, but maybe searched for the wrong things…

1 Like

attributes is a dictionary. A dictionary contains keys and corresponding values. The dictionary’s keys are accessible as a list using keys() and use values() for a list of the dictionary’s values.

Reference

Python dictionary keys()

Python dictionary methods

1 Like