Show calendar title/item (YAML)


I’m trying to create a cool informational “next matchday” calendar for my football matches.
I’ve got the Google Calendar intergrated, in the calendar are all the matchdays.

How can I display the upcoming title of the next event? (e.g. upcoming Saturday it will be my team vs another team). When Saturday is passed show the one for the week next and so on and on…)

I did something similar with my garbage pick-up but as that is using sensors which contains the date it’s a bit easier. I have no clue how to tackle this and show the title of the upcoming calendar item…

Anybody who could help? :slight_smile: Greatly appreciated!

(just for ref, this is the garbage “script” i’ve made)

          waste: >
            {{-'\u26A0\uFE0F'}} Let op, {% set trash_dict = 
            { states('sensor.organic_waste_pickup') : "Groene bak", 
            states('sensor.packages_waste_pickup'): "Plastic bak",
            states('sensor.paper_waste_pickup'): "Papierbak",
            states('sensor.non_recyclable_waste_pickup'): "Grijze bak"} %}
            {% set next_date = trash_dict.keys()|sort|first %}
            {{ trash_dict.get(next_date)}} aan de straat {{ (next_date|as_datetime).strftime("%A, %d %B") }}

Almost got it!

football: >
            {{'\u26BD'}} {{ }}, location {{ }}. Starts at {{}}

However, this shows the date in this format: 2022-09-24 12:00.
How can I set this format to “Saturday, 24 September” ?

Greatly appreciated :smiley:

{{ state_attr('', 'start_time') | as_timestamp | timestamp_custom('%A, %d %B') }}


It’s preferable to use the state_attr() function to get an attribute’s value

{{ state_attr('', 'message') }}

as opposed to referencing it directly

{{ }}

for the reason explained in the documentation’s warning box.


      football: >
        {{'\u26BD'}} {{ state_attr('', 'message') }}, location {{ state_attr('', 'location') }}. Starts at {{ state_attr('', 'start_time') | as_timestamp | timestamp_custom('%A, %d %B') }}
1 Like

Many thanks for your detailled answer, got it working!

1 Like