How to count number of weather stations reporting rain?

I would like to check a condition IF two or more weather stations are reporting rain. I’ve tried multiple ways to get this rain count but anything I’ve tried hasn’t worked. Would you be so kind to help me please!

{% set count = 0 %}
{{ iif( is_state("weather.ipma", "raining" or "pouring"), count + 1, 0) }}  
{{ iif( is_state("weather.met_no_home", "raining" or "pouring"), count + 1, 0) }}  
{{ iif( is_state("weather.open_meteo", "raining" or "pouring"), count + 1, 0) }} 
{{ iif( is_state("weather.accuweather", "raining" or "pouring"), count + 1, 0) }} 
{{ count }}

The delimiters {{ }} are for expressions… they basically just print out the results from whatever is inside them, so your template is just going to print out a few 1s and 0s… Those expression don’t have the ability to assign a new value to count outside their individual bounds.

Community Cookbook - Jinja Delimiters

If you start with a list of entity IDs, you can use the is_state test in a select filter to select against one or more state values:

{% set ents = ["weather.ipma","weather.met_no_home","weather.open_meteo","weather.accuweather"] %}
{{ ents | select("is_state", ["raining","pouring"]) | list | count >= 2 }}
1 Like

Thanks so much @Didgerdrew - I GREATLY appreciate the help!