Skip to content

Resolve entity names through formatEntityName - #187

Closed
bramkragten wants to merge 2 commits into
madmicio:masterfrom
bramkragten:entity-name-options
Closed

bramkragten wants to merge 2 commits into
madmicio:masterfrom
bramkragten:entity-name-options

Conversation

@bramkragten

Copy link
Copy Markdown

What

The three entity dropdowns in the editor (TV entity, and the A/V receiver entity in both branches) labelled their options with states[eid].attributes.friendly_name. friendly_name is the flat legacy name: it does not follow the entity/device/area/floor naming users configure everywhere else in Home Assistant, so the dropdown can show a different name than the rest of the dashboard does for the same entity.

They now go through hass.formatEntityName, the helper the built-in cards use.

The card title uses the same helper, which means name also accepts a structured name:

type: custom:lg-remote-control
entity: media_player.lg_tv
name:
  - type: area
  - type: text
    text: "-"
  - type: entity

Users can therefore compose the title from the device or area name instead of typing a fixed string that goes stale when they rename something. The editor offers Home Assistant's own name picker for this on 2026.4 and later. A plain string name behaves exactly as before, and no title is shown when name is unset, as today.

Compatibility

formatEntityName only accepts a name argument from HA 2026.4; earlier versions expose the same helper with an incompatible signature, and a hass can report a recent version without carrying the helper at all. src/entity-name.ts checks both and falls back to friendly_name otherwise, and the editor keeps the plain text field on those versions, so nothing changes for users who have not updated.

Context

Part of home-assistant/frontend#51686, which tracks moving custom cards off friendly_name.

Testing

npx tsc --noEmit is clean and npm run rollup builds. README documents the extended name option.

🤖 Generated with Claude Code

The three entity dropdowns in the editor labelled their options with the
friendly_name attribute, which is the flat legacy name and ignores the
entity/device/area naming users configure in Home Assistant.

The card title now goes through the same helper, so `name` also accepts a
structured name and can be composed from the device or area name instead
of being a fixed string that goes stale on a rename. The editor offers
Home Assistant's own picker for it on 2026.4 and later, and keeps the
plain text field on older versions, which cannot resolve one.

Ref: home-assistant/frontend#51686

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
formatEntityName returns any string it is given verbatim, the empty one
included, so `name: ''` blanked the label where it previously fell through
to the friendly name. It now reaches the formatter as undefined.

Also drops `parent_device` from the accepted name parts. It only landed in
the frontend on 2026-09-10 and is in no release yet, so under the 2026.4
gate it was silently ignored.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@madmicio madmicio closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants