How to use regex to change display names of all entities in my auto-entites card?

I am displaying all of my relative humidity and temperature (RHT) sensors for various locations in my house using the Auto-Entities card. My card looks like this:

and this is the YAML code:

type: custom:auto-entities
card:
  type: entities
  title: Room Temperatures
filter:
  include:
    - entity_id: sensor.*temperature*

I don’t want each item in the list to display the text “RHT Sensor Temperature ()”. I only want the location, i.e. the text inside the brackets. Is there any way to use regex or something with the “name:” configuration, in order to just change the display name (without renaming each entity)?

Try this

template:
  - sensor:
      - name: "Friendly Sensor Name"
        state: "{{ states('sensor.original_sensor') }}"
        attributes:
          friendly_name: >
            {% if 'temperature' in state_attr('sensor.original_sensor', 'name') %}
              Friendly Temperature Sensor
            {% else %}
              Default Sensor
            {% endif %}

Wrong. This attribute is not treated like a friendly name.

You will have to use a “template” option of auto-entities card.
Example.
Untested:

    filter:
      template: >-
        {% for state in states.sensor | selectattr('entity_id','search','temperature') -%}
          {{
            {
              'entity': state.entity_id,
              'name': state.attributes.friendly_name.split('RHT Sensor Temperature (')[1].replace(')','')
            }
          }},
        {%- endfor %}
1 Like

Perfect. Thanks.