Formatting the loop output from calendar.list_events in telegram message

Hey hey
Im building a telegram message to notify me about upcoming tasks for today.
Therefore I use the new calendar.list_events.
But Ive got problems formatting its output inside my telegram mesage.
The automation looks as follows:

alias: AAAA Kalender GanztagesereignisseTest
description: ""
trigger: []
condition: []
action:
  - service: calendar.list_events
    data:
      duration:
        hours: 24
        minutes: 0
        seconds: 0
    target:
      entity_id: calendar.bestellen
    response_variable: calendartasks
  - service: notify.telegramflorian
    data:
      message: >-
        Your agenda for today:  <p> {% for event in calendartasks.events %}  
        {{event.summary }} <br> {% endfor %} </p>
mode: parallel
max: 10

Ofcourse I need to adjust the duration time and add a trigger - but this is only for testing.
The output looks like this:

Your agenda for today:  <p>        test1 <br>    test2 <br>  </p>

So how to format my telegram notification to make it look like this:
Your agenda for today:
test1
test2

And next question.
How to add every item from my calendar loop to shopping list?

I tried this:

service: shopping_list.add_item
data:
  name: |-
    {% for event in agenda.events %} 
    {{event.summary}} 
    {% endfor %}

But this adds one shopping list entry, with all my calendar entries. Not 1 shopping list entry for every calendar entry :frowning:

  - repeat:
      for_each: "{{ calendartasks.events }}"
      sequence:
        - service: shopping_list.add_item
          data:
            name: "{{ repeat.item.summary }}"
1 Like

I get the Error:

Message malformed: expected dictionary @ data[‘action’][2]

This is a screenshot of my automation (in case of wrong line inset)

You need to remove the hyphen (-) before repeat: when pasting it into the UI like that.

1 Like

Thank you very much.
It’s workin absolutely fine!