Markdown card limit table size

I am using this snippet i found in this forum to display automations triggered

This list is long, i have dozens
How do i limit the table size to be top 10
Im not familiar with this language syntax

{% for state in states.automation
   |selectattr('attributes.last_triggered', 'defined')
   |sort(attribute='attributes.last_triggered', reverse=true) -%}
  {%- set t = now() - state.attributes.last_triggered -%}
  {%- set days = t.days if t.days > 0 else ' ' -%}
  {%- set hrs = t.seconds//3600 %}
  {%- set hrs = hrs if hrs > 0 else ' ' -%}
{% endfor %}
for state in (states.automation
   |selectattr('attributes.last_triggered', 'defined')
   |sort(attribute='attributes.last_triggered', reverse=true))[:10]
1 Like

thank you!

The answer to your question was posted in the original topic. It was in the fourth post and the example demonstrated how to limit the list to 20 items (it can be whatever integer value you desire, such as 10).

1 Like