Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95925

Template to count entities that contain certain characters?

$
0
0

@TMB wrote:

I am trying to get a count (number) of all my entities that contain the word tmpl in the entity_id

I suffix all my template sensors with tmpl to distinguish them from the normal sensors.

I found this code and modified a bit. It returns all the entities as a list.

{%-for state in states 
    if (
          (state.entity_id.endswith("tmpl"))
        )  -%}        
        {%- if loop.first -%}{% elif loop.last -%} {% else -%}  {% endif -%} 
           {{state.name}} {% if state.name.endswith('tmpl')%}  {%else%}  {%endif%}
{% endfor%}

Now my question is; how do I count them?

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95925

Trending Articles