Error: argument of type 'NoneType' is not iterable

Hello

je me mange des erreurs , et je sais pas pourquoi que depuis quelque temps j’ai ca !

Logger: homeassistant.helpers.event
Source: helpers/template.py:425
First occurred: 15:54:57 (14 occurrences)
Last logged: 15:54:57

Error while processing template: Template("{{states.light | reject('in', ['undefined', 'unavailable']) | selectattr('entity_id', 'in', state_attr('light.lumieres_salle_de_bain_full', 'entity_id')) |selectattr('state', 'equalto', 'on') | map(attribute='name') | list | count }}")
Error while processing template: Template("{{states.binary_sensor | reject('in', ['undefined', 'unavailable']) | selectattr('entity_id', 'in', state_attr('binary_sensor.mouvements', 'entity_id'))|selectattr('state', 'equalto', 'on') | map(attribute='name') | list | count}}")
Error while processing template: Template("{% if states('sensor.hacs') | float == 1 and states('binary_sensor.home_assistant_versions_update_available') == 'off' and states('update.home_assistant_operating_system_update') == 'off' and states('update.home_assistant_supervisor_update') == 'off' %} Aucune mise à jour {% elif states('sensor.hacs') | float > 1 or states('binary_sensor.home_assistant_versions_update_available') == 'on' or states('update.home_assistant_operating_system_update') == 'on' or states('update.home_assistant_supervisor_update') == 'on' -%} {%- endif -%} {%- if states('binary_sensor.home_assistant_versions_update_available') == 'on' or states('update.home_assistant_supervisor_update') == 'on' or states('update.home_assistant_operating_system_update') == 'on' %} <b>MàJ Home Assistant :</b><br> {%- if states('binary_sensor.home_assistant_versions_update_available') == 'on' %} HA Core {{state_attr('update.home_assistant_core_update','installed_version')}} -> {{ states('sensor.home_assistant_versions') }}<br> {%- endif -%} {%- if states('update.home_assistant_supervisor_update') == 'on' %} HA Supervisor {{state_attr('update.home_assistant_supervisor_update','latest_version')}}<br> {%- endif -%} {%- if states('update.home_assistant_operating_system_update') == 'on' %} HassOS {{ states('sensor.home_assistant_operating_system_version') }} → {{ states('sensor.home_assistant_operating_system_newest_version') }}<br> {%- endif -%} {%- endif -%} {%- if states('sensor.hacs') | float > 1 %} <b>MàJ Hacs :</b><br> {% for repo in states.sensor.hacs.attributes.repositories -%} {{ repo.display_name }} ({{ repo["available_version"] }})<br> {% endfor %} {%- else -%} {%- endif -%}")
Error while processing template: Template("{{states.binary_sensor | reject('in', ['undefined', 'unavailable']) | selectattr('entity_id', 'in', state_attr('binary_sensor.portes', 'entity_id'))|selectattr('state', 'equalto', 'on') | map(attribute='name') | list | count}}")
Error while processing template: Template("{% set open_doors = states | selectattr('entity_id', 'in', state_attr('binary_sensor.portes','entity_id')) | selectattr('state','in',['on','open']) | map(attribute='name') | list %} {% if open_doors | length == 1 %} Attention, la {{ open_doors[0] }} est ouverte. {% else %} Attention, les {{ open_doors[:-1] | join(' , ') }}{{' ,' if open_doors | length > 2 else ' '}} et {{ open_doors[-1]}} sont ouvertes {% endif %}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 423, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1950, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.10/site-packages/jinja2/async_utils.py", line 45, in wrapper
    return normal_func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/filters.py", line 1324, in sync_do_list
    return list(value)
  File "/usr/local/lib/python3.10/site-packages/jinja2/filters.py", line 1467, in sync_do_map
    for item in value:
  File "/usr/local/lib/python3.10/site-packages/jinja2/filters.py", line 1764, in select_or_reject
    for item in value:
  File "/usr/local/lib/python3.10/site-packages/jinja2/filters.py", line 1765, in select_or_reject
    if func(item):
  File "/usr/local/lib/python3.10/site-packages/jinja2/filters.py", line 1750, in <lambda>
    return lambda item: modfunc(func(transfunc(item)))
  File "/usr/local/lib/python3.10/site-packages/jinja2/filters.py", line 1745, in func
    return context.environment.call_test(name, item, args, kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 589, in call_test
    return self._filter_test_common(
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 545, in _filter_test_common
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/tests.py", line 212, in test_in
    return value in seq
TypeError: argument of type 'NoneType' is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 540, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 425, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: argument of type 'NoneType' is not iterable

Mon fichier sensor:

      systeme_avertissement:
        friendly_name: Surveillance systeme
        value_template: >-    
              {% set time  = ((as_timestamp(now()) - as_timestamp(states.sensor.compteur_thermo_hs.last_changed)) /60) | round(0) %}
              {% if  states('sensor.compteur_thermo_hs') | float(0) > 4 and time > 5  -%}
                  <b>Bluetooth HS</b> depuis {{ as_timestamp(states.sensor.compteur_thermo_hs.last_changed) | timestamp_custom("%Hh%M") }} ({{relative_time(states.sensor.compteur_thermo_hs.last_changed)}})<br>
              {% else -%}
              {% endif -%}
              
              {%- if states('sensor.compteur_lumieres_hs') | float(0) > 0  -%}
               {% set lum_hs = states | selectattr('entity_id', 'in', state_attr('light.tout','entity_id')) | selectattr('state','in',['','unavailable']) | map(attribute='name') | list %}
               {% if lum_hs | length == 1 -%} 
              <b>Lumière HS :</b> {{ lum_hs[0] }}<br>
               {% else -%}
               <b>{{ states('sensor.compteur_lumieres_hs') }} lumières HS :</b> {{ lum_hs[:-1] | join(' , ') }}{{' ,' if lum_hs | length > 2 else ' '}} et {{ lum_hs[-1]}}<br>
               {% endif -%}
              {% else -%}
              {% endif -%}
              
              {% set porte_hs = states | selectattr('entity_id', 'in', state_attr('binary_sensor.portes','entity_id')) | selectattr('state','in',['','unavailable']) | map(attribute='name') | list %}
              {%- if porte_hs | length == 0 -%} 
              {%- elif porte_hs | length == 1 -%} 
               <b>Porte HS :</b> {{ porte_hs[0] }}<br>
              {%- else -%}
               <b>Porte HS :</b> {{ porte_hs[:-1] | join(' , ') }}{{' ,' if porte_hs | length > 2 else ' '}} et {{ porte_hs[-1]}}<br>
              {%- endif -%}              
              
              {% set mouv_hs = states | selectattr('entity_id', 'in', state_attr('binary_sensor.mouvements','entity_id')) | selectattr('state','in',['','unavailable']) | map(attribute='name') | list %}
              {%- if mouv_hs | length == 0 -%} 
              {%- elif mouv_hs | length == 1 -%} 
               <b>Mouvement HS :</b> {{ mouv_hs[0] }}<br>
              {%- else -%}
               <b>Mouvements HS :</b> {{ mouv_hs[:-1] | join(' , ') }}{{' ,' if mouv_hs | length > 2 else ' '}} et {{ mouv_hs[-1]}}<br>
              {%- endif -%}              
              
              {%- if states('sensor.compteur_zigbee_hs') | float(0) > 0  -%}
               {% set lum_hs = states | selectattr('entity_id', 'in', state_attr('group.zigbee','entity_id')) | selectattr('state','in',['','unavailable']) | map(attribute='name') | list %}
               {% if lum_hs | length == 1 -%} 
               <b>Appareil HS :</b> {{ lum_hs[0] }}<br>
               {% else -%}
                <b>Appareils HS :</b> {{ lum_hs[:-1] | join(' , ') }}{{' ,' if lum_hs | length > 2 else ' '}} et {{ lum_hs[-1]}}<br>
               {% endif -%}
              {% else -%}
              {% endif -%}        
              
              {%- if states('sensor.compteur_echo_hs') | float(0) > 0  -%}
              {% set open_doors = states | selectattr('entity_id', 'in', state_attr('group.echos','entity_id')) | selectattr('state','in',['on','unavailable']) | map(attribute='name') | list %}
               {% if open_doors | length == 1 -%} 
                <b>Echo HS :</b> {{ open_doors[0] }}<br>
               {% else -%}
                <b>{{ states('sensor.compteur_echo_hs') }} Echos HS :</b> {{ open_doors[:-1] | join(' , ') }}{{' ,' if open_doors | length > 2 else ' '}}et {{ open_doors[-1]}}<br>
               {% endif -%}
              {% endif -%}
              
              {% set time  = ((as_timestamp(now()) - as_timestamp(states.sensor.compteur_thermo_hs.last_changed)) /60) | round(0) %}
              {% if  states('sensor.compteur_thermo_hs') | float(0) > 0 and time > 5  -%}
               {% set lum_hs = states | selectattr('entity_id', 'in', state_attr('group.thermo','entity_id')) | selectattr('state','in',['','unavailable']) | map(attribute='name') | list %}
               {% if lum_hs | length == 0 -%} 
               {% elif lum_hs | length == 1 -%} 
               <b>Thermomètre HS</b> : {{ lum_hs[0] }}<br>
               {% else -%}
                <b>{{ states('sensor.compteur_thermo_hs') }} Thermomètres HS :</b> {{ lum_hs[:-1] | join(' , ') }}{{' ,' if lum_hs | length > 2 else ' '}} et {{ lum_hs[-1]}}<br>
               {% endif -%}
              {% else -%}
              {% endif -%}
              
              {%- if states('sensor.disk_use_percent_home')| float(0) > 70.0 -%}
              <b>Espace DD</b> {{states('sensor.disk_use_percent_home')}}%<br>
              {% endif -%}             
              {%- if states('sensor.cpu_temperature')| float(0) > 65 -%}
               <b>CPU</b> {{states('sensor.cpu_temperature')}}°<br>
              {% endif -%}
              
              {% set interr_hs = states | selectattr('entity_id', 'in', state_attr('group.interrupteurs','entity_id')) | selectattr('state','in',['','unavailable']) | map(attribute='name') | list %}
              {% if interr_hs | length == 0 -%}
              {% elif interr_hs | length == 1 -%}
              <b>Interrupteur HS :</b> {{ interr_hs[0] }}
              {% else -%}
              <b>Interrupteurs HS :</b> {{ interr_hs[:-1] | join(' , ') }}{{' ,' if interr_hs | length > 2 else ' '}} et {{ interr_hs[-1]}}
              {% endif -%}              
              
              {% set compteur_pile_faible =
              states.sensor                  
              | selectattr('attributes.device_class', 'defined') 
              | selectattr('attributes.device_class', '==', 'battery') 
              | rejectattr('state', 'in', ['unavailable', 'unknown'])
              | rejectattr('state', 'eq', '100')   
              | selectattr('state', 'lt', '20')
              | map(attribute='name') | list | count%}
              {%set pile_faible =
              states.sensor                  
              | selectattr('attributes.device_class', 'defined') 
              | selectattr('attributes.device_class', '==', 'battery') 
              | rejectattr('state', 'in', ['unavailable', 'unknown'])
              | rejectattr('state', 'eq', '100')   
              | selectattr('state', 'lt', '20')
              | map(attribute='name') | list | join(' , ')%}
              {%set etat_pile_faible =
              states.sensor                  
              | selectattr('attributes.device_class', 'defined') 
              | selectattr('attributes.device_class', '==', 'battery') 
              | rejectattr('state', 'in', ['unavailable', 'unknown'])
              | rejectattr('state', 'eq', '100')   
              | selectattr('state', 'lt', '20')
              | map(attribute='state') | list | join(' , ')%}
              {% if compteur_pile_faible | float(0) == 0 -%}
              {% elif compteur_pile_faible | float(0) == 1 -%}
                  <b>Batterie faible :</b> {{ pile_faible }} {{ etat_pile_faible }}%
              {% else -%}
                  <b>{{ compteur_pile_faible }} batteries faibles :</b> {{ pile_faible }}
              {% endif -%}              

Salut,

Teste tes différents SET à la main dans les outils de dev. A tous les coups, il doit y avoir un truc vide au lieu d’une liste

Re,

merci je vais m’orienté sur cette piste