How to modify template for choosing majority weather condition

Hi there, I am currently using the following template

  - sensor:
    - name: "Weather Conditions"
      icon: >
        {{ 'mdi:'~ iif( this.state == 'exceptional', 'alert-circle', 
        'weather-'~this.state | replace('_', '-'))  }}
      state: >
        {% set ns = namespace(list = []) %}
        {%- for state in | groupby("state") %}
          {%- set ns.list = ns.list + [(state[0], state[1] | list | count)] %}
        {%- endfor %}
        {{ (ns.list | sort(attribute=1, reverse=true) | first)[0] }}
        majority_condition_count: "{{ | selectattr('state', 'eq', this.state) | list | count}}"

which works fine, but it does include any weather domain. I have 2 which are Astroweather and and these ones should be NOT included in the template
How do I do it ?
I played around with the ‘developer tools - template’ but I am not really good in coding, please excuse. Also checked the home assistant Template info page.
Does anyone have an idea on how to explicitly specify which weather domains should be used or exclude the ones I don’t want to use

i’m a little confused.

this sensor is designed to look at a bunch of weather services and pick the most common forecast among them. are you saying you only have 2 and want to pick one to exclude? if so, why bother with this at all?

or are you saying you have many (like 5+) and you want to exclude 2 of the 5?

Yes exactly. My mistake not to have been clear before. In total I have 5 weather domains.
Accuweather, Openweathermap, Meteoswiss, and Astroweather and I only want this template to use Accuweather, Openweathermap, Meteoswiss

Forgot to mention, the template is obviously not mine.
Big thanks to Didgeridrew. Template to find majority?

Does anybody have an idea how to tackle it?

Replace with the three weather entities you want to use and expand them.

expand('weather.foo1', 'weather.foo2', 'weather.foo3')

thanks so much 123 Taras, that is doing the trick

1 Like