#Having trouble using a response_variable in an automaton

1 messages · Page 1 of 1 (latest)

icy horizon
#

I'm trying to write an automaton to export certain calendar events to my todo list. The rub is when I try to check the todo list to see if that event already exists; for some reason it doesn't work.

Full automaton: https://bin.lain.pw/upload/otter-whale-sheep

Looking at the trace, the first step produces:

tasklist:
  todo.recurring:
    items:
      - summary: Take out the trash
        uid: 8a9f0514-4634-11f0-8c3e-107b44913c19
        status: needs_action
        due: '2025-06-10'

But by the time we get to setting task_exists, the loop always fails. I've tried simlifying it to the point it always sets true as long as we iterate even once, but even that fails, so it implies I'm either constructing the loop wrong, or we're losing tasklist before we get there.

What am I doing wrong?

elder belfry
#
                  {% set found = false %} 
                  {% for item in tasklist['todo.recurring']['items'] %}
                    {% if item.summary == repeat.item.summary %}
                      {% set found = true %}
                    {% endif %}
                  {% endfor %} 
                  {{ found }}

Jinja scopes don't work like this

#

you can't override a higher scope variable inside a for loop

icy horizon
#

That's a very common loop structure... What's the jinja compatible way to write this kind of lookup?

elder belfry
#

yeah it's annoying 😬

icy horizon
#

I swear every time I need to write an automation that's more than 5 lines I just wish I just had a "Let me write a blob of code" operator.

elder belfry
#

You need to use a namespace(), looking for a good documented example but drawing a blank 🤔

icy horizon
#

That's enough of a thread for me to pull on, thanks.

icy horizon
#

Alternatively I bet I could just make it a list and append then check length smile

#

Ok yeah that works. Now to draw the rest of the owl