If having entities, starting with a number, the template string itself is rendered.
E.g. {% set switches = [states.switch.1_entity,states.switch.entity_2] %} {{ switches | selectattr('state','eq','on') | list | count }}
where states.switch.1_entity isn't valid, and should be states.switch['1_entity'].
If having entities, starting with a number, the template string itself is rendered. E.g.
{% set switches = [states.switch.1_entity,states.switch.entity_2] %} {{ switches | selectattr('state','eq','on') | list | count }}
where
states.switch.1_entity
isn't valid, and should bestates.switch['1_entity']
.See https://www.home-assistant.io/docs/configuration/templating/#entity_id-that-begins-with-a-number for more information on this.
I seems like the
states.switch['entity']
syntax is valid for any entity.