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

Counting issue in template with for loop

$
0
0

@Mariusthvdb wrote:

trying to count the number of persistent notifications with the string ‘rss_feeds’ I had this for loop, and I do think it worked correctly before:

          {% for state in states.persistent_notification  %}
            {% if 'rss_feed' in state.entity_id %}
              {% if loop.first %}{{loop.length}}
              {% endif %}
            {% endif %}
          {% endfor %}

I had an issue in case of 0, since this template then shows nothing… but, and this is what’s more surprising now, it doesnt even count at all anymore…

check this:

showing correctly there are 3 pers notifications, and 1 of them has the string ’ rss_feed’ in its entity_id:

yet the template shows nothing:

what am I doing wrong here, to not have it show 1, and, how can I show 0 if there is no notification with the string in the entity_id?

a binary_sensor test works fine too:

    {% set feed = states.persistent_notification
                |map(attribute='object_id')
               |join %}
    {{'rss_feed' in feed }}


thanks for having a look

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>