How to mass rename friendly name in Frontend (auto-entity card)?

Hey there,
I’m using the auto-entity card to display my battery powered entities.

Code:

card:
  show_header_toggle: false
  title: Battery levels
  type: custom:bar-card
  severity:
    - color: Red
      from: 0
      to: 10
      icon: mdi-battery-alert-variant-outline
    - color: Red
      from: 11
      to: 15
      icon: mdi-battery-low
    - color: Orange
      from: 26
      to: 50
      icon: mdi-battery-medium
    - color: Green
      icon: mdi:battery-high
      from: 51
      to: 100
filter:
  include:
    - entity_id: '*battery'
type: custom:auto-entities
show_empty: true
sort:
  method: state
  numeric: true
  reverse: true

The friendly name for the battery sensor is always entity name + battery.
As i’m only showing battery entities here, the amended battery is redundant, therefore i’d like to remove it.
Is there any way to strip the battery from the friendly name?
Currently it looks like this:

thanks in advance.

try this (untested):

    filter:
      template: >-
        {% for state in states.sensor -%}
          {%- if state.entity_id | regex_match("sensor.battery_", ignorecase=False) -%}
            {{
              {
                'entity': state.entity_id,
                'name': state.attributes.friendly_name.split(' battery')[0]
              }
            }},
          {%- endif -%}
        {%- endfor %}
5 Likes

yes! Exactly I was looking for. Thanks :slight_smile: