Template pointer -- warning for freezing forecast

Inexperienced coder here. Looked through Jinjya documentation again, but nothing jumped out at me. Looking for a pointer.

Goal: Display an icon if ANY low temperature within the five-day forecast dips below, say, 2 degrees C.

Progress: Was easy enough to parse out the five-day forecast – output as a list with five numerals – but I’m not quite sure how to write the logic for the next part. Don’t think I can use ‘in’ because the left side wants only a single input, and I’m unsure how to go about coding something like:

‘If any numeral in the list is less than X, output true’

Any quick tips?

You could use the min of the five values and compare this to your threshold. When the min is above the threshold, none of the values is below the threshold. When the min is below the threshold at least one of the values is below the threshold.

I have never managed with the filters, but this is a solution in case anyone else doesn’t speak up on how to filter the list.

{% set flag = namespace(flag=false) %}      

{% for value in state_attr('weather.smhi_home', 'forecast')[1:5] -%}
{% if (value.templow < 2  and flag.flag == false) %}
true
{% set flag.flag = True %}
{%- endif %}
{%- endfor %}

So create a flag to stop looking at the rest of the forecast if one is less than 2 degrees.

Will try out the second solution as well… one problem I ran into with the first ‘min’ solution.

{{state_attr('weather.geneve_cointrin', 'forecast')|join(',', attribute="templow")|min}}

‘Min’ returns nothing, while ‘max’ returns the highest integer. Although the template designer says the join call is returning a list, it seems like ‘min’ and ‘max’ are working against a string rather than a proper list of integers.

This selects the lowest value of templow.

{{ state_attr('weather.your_location', 'forecast') | map(attribute='templow') | min }}

This tests if the result is less than 2.

{{ state_attr('weather.your_location', 'forecast') | map(attribute='templow') | min < 2 }}