maxwroc / battery-state-card

Battery state card for Home Assistant
MIT License
848 stars 38 forks source link

Add support for name_template #728

Open Superkikim opened 2 months ago

Superkikim commented 2 months ago

Is your feature request related to a problem? Please describe. I use autoentity to get the state of all batteries in my home assistant. I'd like to extract the device name, rather than have the entity name showed by the battery-state-card. Unfortunately, it seems name_template is not supported by battery-state-card.

In the example below, name_template is ignored:

type: custom:auto-entities
card:
  type: custom:battery-state-card
  name_template: '{{ device_attr(config.entity, "name_by_user") or device_attr(config.entity, "name") or state_attr(config.entity, "friendly_name") }}'
filter:
  include:
    - entity_id: '*battery*'
      options:
        tap_action:
          action: more-info
  exclude:
    - entity_id: '*state'
    - entity_id: '*health'
    - entity_id: '*power'
    - entity_id: '*temperature'
    - entity_id: '*range'
    - domain: binary_sensor
sort:
  method: state
  reverse: false
  numeric: true

Describe the solution you'd like Add the support for name_template to battery-state-card so we can automate and customize entity naming

Additional context Well, I believe the above description says it all ;-)