Markdown card limit table size

hello
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

|D|H|M||Name|
|----:|----:|----:|:--:|:----|
{% for state in states.automation
   |selectattr('attributes.last_triggered', 'defined')
   |selectattr('attributes.last_triggered')
   |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 ' ' -%}
  |{{days}}|{{hrs}}|{{(t.seconds//60)%60}}||_{{state.name}}_|
{% endfor %}
for state in (states.automation
   |selectattr('attributes.last_triggered', 'defined')
   |selectattr('attributes.last_triggered')
   |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