#Issue parsing value into an input_text

6 messages · Page 1 of 1 (latest)

hazy trail
#

Hello I m trying to create get events and parse it into a text field to display notification regarding the school lunch of my daughter. I have the following output getting my events :

  calendar.repas_ecole:
    events:
      - start: '2024-09-26T00:00:00+02:00'
        end: '2024-09-26T01:00:00+02:00'
        summary: Potages
      - start: '2024-09-26T00:00:00+02:00'
        end: '2024-09-26T01:00:00+02:00'
        summary: Tartines`

And here is the complete script : https://pastebin.com/6tptzf4D

But I m pretty sure this is the faulty part :

 {% set meals_info = [] %} {% for event in
                meals['calendar.repas_ecole'].events %}
                  {% set meals_info = meals_info + [event.summary] %}
                {% endfor %} {{ meals_info | join(', ') }}

Thanks for your help

honest ore
#

You need to use a namespace:

{% set ns = namespace(meals=[]) %}
{% for event in meals[‘calendar.repas_ecole’].events %}
{% set ns.meals = ns.meals + [event.summary] %}
{% endfor %}
{{ ns.meals | join(‘, ‘) }}
severe idol
#

also watch the max character length of input_text

hazy trail
#

Getting these data was a hell ^^'
I got a mail confirmation in my proton mail box after selecting meal in the school app, send the mail in gmail, use it to trigger a make scenario, parse the mail with a regex to get the event, recompose the date to an us format, create google calendar event

Then do this automation to send a notification every morning
Just because we forgot once to prepare the meal xD

#

It's working thanks