Replace String in Stack Card

I have a Horizontal Stack card in my dashboard to show the battery levels of devices but for each one the word “Battery” or “Battery Level” is repeated and I want to try to clean it up by replacing those strings with a blank string.

How would I go about that?

Current code:

  - type: custom:auto-entities
    card:
      show_header_toggle: false
      title: Good
      type: entities
      state_color: false
      card_mod:
        style: |
          ha-card .card-header {
            font-size: 14px;
            color: white;
            font-weight: 600
          }
          ha-card {
              #states > div {
                margin: -15px 0px !important;
              }
            .card-content hui-sensor-entity-row:
              $:
                hui-generic-entity-row:
                  $: |
                    .info {
                      margin-left: 0px !important;
                     }
            --mdc-icon-size: 18px !important;
            --paper-item-icon-color: lime;
            font-size: 12px !important;
            padding: 0px 0px 0px !important;
            width: 400px !important;
            font-weight: 200;
            background: none;
            .card-content div {
              margin-top: 0px !important;
              margin-bottom: 0px  !important;
            }
          }
    filter:
      include:
        - attributes:
            device_class: battery
          state: <= 100
      exclude:
        - name: /[Ll]ow/
        - name: /[Ss]tate/
        - name: iPad M Battery Level
        - name: Martin's MACBook Battery
        - name: iPhone M App Battery Level
        - name: iPhone R App Battery Level
        - state: < 70
    sort:
      method: state
      numeric: true
    show_empty: false

Current output:

Card-mod code is rather wrong.
Suggest to start learning it from simpler tasks.
All questions better to ask here.

Hi the card works as expected. The above code is just the part of the code directly related to the screenshot, not the code for the whole page.

ok, if you say so

1 Like

card_mod is about CSS, style, it is not meant to change content.
If you want to change the name, go to the entity, click the gear icon and change it.

Seems that card-mod code (wrong as I said) here only for distracting from an actual issue.
The issue is that a person needs to automatically strip names from some substring (not touching states object itself) which may only be done by templating (“template” option in auto-entities).

Agree, I’m just wondering why not change the name once for all, because if it is used in some other cards, the “battery” or “battery percentage” will be annoying again.

But I did not pay attention to the card_mod part as it is not relevant for the OP.

Here is man (me) who defines friendly names only for some entities like “person”.
+avoiding using Ui.

So do I. But when it is bothering me, I do, what is done is done :slight_smile:
I’ve an old 2018 “customize.yaml” file that I should (partially) replace with some UI actions btw.

You still keep using ONE file? ))))
Have you heard about “splitting config”?
I have “customize” wherever I need it.

Is not a big file, only 18 main tags. Legacy from the good old days.