Display multiple attributes with the same name?

I’m using NWS alerts. I’m in Florida so we have a lot of alerts right now. However if there is more than 1 alert the attribute will be used multiple times. Here’s an example of the current sensor state.

Below is an example of attributes that will be used multiple times.

Headline: A STRONG THUNDERSTORM WILL IMPACT SOUTHEASTERN PASCO...WEST CENTRAL POLK AND NORTHEASTERN HILLSBOROUGH COUNTIES THROUGH 145 PM EDT
Status: Actual
Message Type: Alert
Severity: Moderate
Certainty: Observed
Onset: 2024-08-03T12:50:00-04:00
Expires: 2024-08-03T13:45:00-04:00
Description: At 1250 PM EDT, Doppler radar was tracking a strong thunderstorm near
Fussels Corner, or near Auburndale, moving west at 35 mph.




Headline: HEAT ADVISORY REMAINS IN EFFECT UNTIL 6 PM EDT THIS EVENING
Status: Actual
Message Type: Update
Severity: Moderate
Certainty: Likely
Onset: 2024-08-03T12:00:00-04:00
Expires: 2024-08-03T18:00:00-04:00
Description: * WHAT...Heat index values up to 110 expected.

I do it in a markdown card like this:

type: markdown
entity_id: sensor.nws_new_orleans
content: |
{%- if states('sensor.nws_new_orleans') | int > 0 -%}
  {%- for alert_num in range(states('sensor.nws_new_orleans') | int) -%}
	{% if alert_num > 0 %}

---
	{% endif %}
# NWS Alert {{ alert_num + 1 }}
	{% if state_attr('[[nwssensor]]', 'title').split(' - ')[alert_num] is defined %}
## {{ state_attr('sensor.nws_new_orleans', 'title').split(' - ')[alert_num] }}
   {{ state_attr('sensor.nws_new_orleans', 'display_desc').split('\n\n-\n\n')[alert_num] }}
	{% else %}
	  None
	{% endif %}
  {% endfor %}
{% else %}
  # None
{% endif %}

That worked with a few modifications. Thanks!

type: markdown
entity_id: sensor.nws_alerts
content: |
{%- if states('sensor.nws_alerts') | int > 0 -%}
  {%- for alert_num in range(states('sensor.nws_alerts') | int) -%}
	{% if alert_num > 0 %}

---
	{% endif %}
# NWS Alert {{ alert_num + 1 }}
	{% if state_attr('sensor.nws_alerts', 'title').split(' - ')[alert_num] is defined %}
## {{ state_attr('sensor.nws_alerts', 'title').split(' - ')[alert_num] }}
   {{ state_attr('sensor.nws_alerts', 'display_desc').split('\n\n-\n\n')[alert_num] }}
	{% else %}
	  None
	{% endif %}
  {% endfor %}
{% else %}
  # None
{% endif %}
1 Like