List and filter entities to show state in markdown

Hello, i have a probelm.

I go lot of sensors for my locked door or windows :

image

What i want to do is this :
image
When alarm is armed (or armed_away etc…) i want show smalls informations like: covers all down or some up, locked door o windows OK etc…

My code :

type: conditional
conditions:
  - condition: state
    entity: alarm_control_panel.alarme
    state: armed_away
  - condition: or
    conditions:
      - condition: state
        entity: alarm_control_panel.alarme
        state: armed_custom_bypass
  - condition: or
    conditions:
      - condition: state
        entity: alarm_control_panel.alarme
        state: armed_home
  - condition: or
    conditions:
      - condition: state
        entity: alarm_control_panel.alarme
        state: armed_night
  - condition: or
    conditions:
      - condition: state
        entity: alarm_control_panel.alarme
        state: armed_vacation
card:
  type: markdown
  content: >-
    {% if is_state('cover.tous_les_volets', 'off') %}
      <ha-alert title="Volets" alert-type="success">Tous les volets sont fermés</ha-alert>
    {% else %}
      <ha-alert title="Volets" alert-type="info">
        Il y a des volets ouverts
      </ha-alert>
    {% endif %}


    {% set statePorteEntree = states('sensor.verrou_porte_entree') %}

    {% set statePorteCellier = states('sensor.verrou_porte_cellier') %}

    {% set stateBaieAvantDroit = states('sensor.verrou_baie_avant_droit') %}

    {% set stateBaieAvantGauche = states('sensor.verrou_baie_avant_gauche') %}

    {% set stateBaieArriereDroit = states('sensor.verrou_baie_arriere_droit') %}

    {% set stateBaieArriereGauche = states('sensor.verrou_baie_arriere_gauche')
    %}

    {% set stateFenetreWC = states('sensor.verrou_fenetre_wc') %}

    {% set stateFenetreCellier = states('sensor.verrou_fenetre_cellier') %}


    {% if 
      statePorteEntree == "LOCKED" and
      statePorteCellier == "LOCKED" and
      stateBaieAvantDroit == "LOCKED" and
      stateBaieAvantGauche == "LOCKED" and
      stateBaieArriereDroit == "LOCKED" and
      stateBaieArriereGauche == "LOCKED" and
      stateFenetreWC == "LOCKED" and
      stateFenetreCellier == "LOCKED"
    %}

    <ha-alert title="Verrous" alert-type="success">Tout est fermé</ha-alert>

    {% else %}

    <ha-alert title="Volets" alert-type="warning">Il y a des portes ou fenêtres
    ouvertes</ha-alert>

    {% endif %}
  title: Alarme activée

  1. I wanted to know, if state of alarm like : any armed state exist ?
  2. Is there a simpler solution to retrieve the sensors.verrou_* entities with the openState attribute to know if everything is LOCKED or not?

I tryied to make a sensor group but i’v got state: undifined because he try to do math operation on values.

Thank you for your help

I think the cleanest solution is to create a helper, template sensor and use value template to return if all sensors are in a particular state, something like this, then whatever card you decide to use it’s just one value.

{{ 
  is_state('person.person1', 'home') 
  or is_state('person.person2', 'home')
  or is_state('person.person3', 'home')
}}

Also if the sensors are in a domain you could use something like this (not tested but use development tools, templates to perfect:

          {{
            states.light | selectattr('state', 'eq', 'off') | list | count ==
            states.light | list | count
          }}