UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'current' error

Hi I was using this code and a month or so ago it stopped working, possibly with a core update. I cant find help on automation attributes, can someone post a link to them?

The error: UndefinedError: ‘homeassistant.util.read_only_dict.ReadOnlyDict object’ has no attribute ‘current’

The code (in a markdown card):

|D|H|M|S||Name|
|----:|----:|----:|----:|:--:|:----|
{% for state in states.automation
   |selectattr('attributes.current', 'eq', 1)
   |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 %}

Add

| selectattr('attributes.current','defined')

Seems that you got unavailable / restored automations.

I have the same problem, but still cannot understand WHERE to put your code.

Actually i have this markdown:

          content: >
            # <font color= grey> Allarme Abruzzo:  {{
            states.binary_sensor.allarme_meteo_abruzzo.state }} </font> 

            ___

            **Alarm code**

            <font color= {{ states.sensor.severita_meteo_abruzzo.state }}>  {{
            states.sensor.severita_meteo_abruzzo.state }} </font>

            <font color= {{ states.sensor.severita_meteo_abruzzo.state }}>  {{
            states.binary_sensor.allarme_meteo_abruzzo.attributes.awareness_level
            }} </font>

            <font color= {{ states.sensor.severita_meteo_abruzzo.state }}>  {{
            states.binary_sensor.allarme_meteo_abruzzo.attributes.awareness_type
            }} </font>

            **Headline**

            <font color= #4caf50> {{
            states.binary_sensor.allarme_meteo_abruzzo.attributes.headline }}
            </font>

            **Event**

            <font color= #4caf50> {{
            states.binary_sensor.allarme_meteo_abruzzo.attributes.event }}
            </font>

            **Status**

            <font color= #4caf50> {{
            states.binary_sensor.allarme_meteo_abruzzo.attributes.description }}
            </font>

            ___ 

How and where to use your advice?