I currently have a script that builds a complex voice announcement in the message field of the announce action.
For better debugging (mostly) I want to define parts of it as variables.
But the way the message is built doesn't work too well with functional style templating and uses iterative loops.
I don't see a straightforward way to get this template split and hooked into the "Define Variable" action.
I don't want to build the entire text, but the lists currently accumulated in the acc namespace.
{% set today = today_at() %}
{% set tomorrow = today_at("23:59") %}
{% set acc = namespace(due= [], overdue= [], other= action_response['todo.display']['items'] | selectattr('due', 'undefined')) %}
{% for item in action_response['todo.display']['items'] | selectattr('due', 'defined') %}
{% set itemtime = strptime(item.due, "%Y-%m-%d") | as_local %}
{% if itemtime < tomorrow %}
{% if itemtime > today %}
{% set acc.due = acc.due + [item] %}
{% else %}
{% set acc.overdue = acc.overdue + [item] %}
{% endif %}
{% else %}
{% set acc.other = acc.other + [item] %}
{% endif %}
{% endfor %}
{% if acc.due %}
Tasks Today:
{% for item in acc.due -%}
{{ item.summary }};
{% endfor -%}
{% endif -%}
{% if acc.overdue %}
Tasks overdue:
{% for item in acc.overdue -%}
{{ item.summary }};
{% endfor -%}
{% endif -%}
{% if acc.other %}
Unscheduled Tasks:
{% for item in acc.other -%}
{{ item.summary }};
{% endfor -%}
{% endif %}