I have an idea but I first need to see rest of what is in the repeat.
- repeat:
for_each: >
{% for _schedule in expand(_schedules) %}
... show the rest of what is in the repeat ...
FWIW, the “idea” is to make for_each iterate through each one of the four schedules individually (do not expand them in advance) and then expand each schedule in the sequence. However, that all depends on what else you’re doing in for_each. It’s unclear to me why you’re using a Jinja2 for-loop in a repeat for_each.
{% for _schedule in _schedules %}
{% set _schedule = expand(_schedule) %}
...
But is expand() even necessary? What is it going to provide you, in this context, that using states() or states_attr() won’t? If you need access to the state object properties like “last changed” you can use bracket notation, i.e. state[_schedule].last_changed