Dynamic 'name' for state

I’m trying to create a card that shows my battery state of charge (home solar) but will also update the ‘name’ shown in the card with the ‘Time Remaining’ on the batteries which is another entity ‘state’.

If I type the following into the developer ‘template’ section - I get the required result:

Battery Discharging: {{states('sensor.nr_batterytimeleft')}} left.

GIVES
Battery Discharging: 12hrs 30mins left.

But when I’m using that same code within the ‘Name’ string of another card, it just shows as text.

card:
      type: custom:bar-card
      entities:
        - entity: sensor.nr_pylontechsoc
          direction: right
          name: Battery Discharging {{states('sensor.nr_batterytimeleft')}}
          color: green
          min: '0'
          max: '97'
          severity:
            - color: Red
              from: 0
              to: 35
            - color: Orange
              from: 36
              to: 50
            - color: Green
              from: 51
              to: 100
          animation:
            state: 'on'
            speed: '20'
          positions:
            icon: 'off'
            indicator: 'off'
      positions:
        indicator: 'off'
        icon: 'off'

Is there a way to do this?

Thanks,
Matt

The custom-bar-card does not support templating the name.

You may be able to do it with this:

Thanks Tom, glad to see it wasn’t my lack of googling / searching / code!

I’ll look into your link - thank you!