Conditional test error in template

Hi there,

I want to test in a script if all elements in a group of windows are at a given position.
I tried in template developer tools:

{% set positions = expand('cover.toutes_les_fenetres_velux') | map(attribute='attributes.current_position') %}
{% set p=1 %}
{{ max(positions)>p or min(positions)<p }}

But get the error: UndefinedError: No aggregated item, sequence was empty.

Then I made different tries and was very surprised that the folowing test fails:

{% set positions = expand('cover.toutes_les_fenetres_velux') | map(attribute='attributes.current_position') %}
{% set p=1 %}
{{ max(positions)>p }}
{{ min(positions)<p }}

But this works:

{% set positions = expand('cover.toutes_les_fenetres_velux') | map(attribute='attributes.current_position') %}
{% set p=1 %}
{{ max(positions)>p }}

And the same for the other test. But the fact that I call two times the variable positions fails. Can anyone explain why?

Post the value of the positions variable.