Repository navigation
Resolve entity name via hass.formatEntityName - #93
Open
bramkragten wants to merge 3 commits into
Open
bramkragten wants to merge 3 commits into
bramkragten wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Resolve the
nameoption throughhass.formatEntityNameinstead of readingattributes.friendly_namedirectly, and offer theentity_nameselector in the visual editor.Why
Home Assistant is moving from a single
friendly_namestring to a name composed from the entity's registry context (entity, device, area, floor). Under that model the device name becomes part of the composed name, so a button reads "Kitchen Ceiling light" where the built-in cards next to it show "Ceiling light" — and on a slider button, where the name shares the tile with the slider, that extra length wraps. Cards reading the attribute directly also can't follow the default when HA changes it.Routing through the helper fixes both, and users can compose the name:
Context: home-assistant/frontend#51686, which tracks bringing the most-used custom cards along with the new naming model.
Changes
Controller.namegoes throughcomputeEntityNamein the newsrc/entity-name.ts.SliderButtonCardConfig.namewidens fromstringto a newEntityNametype.ha-selectorwithentity_nameon HA 2025.11+, falling back to the existingmwc-textfieldbelow that, so the visual editor keeps working on older versions. It needs its own handler becauseha-selectorreports throughev.detailrather thantarget.value.shouldUpdatealso returns true when the naming inputs change.formatEntityNameresolves against the registries and HA swaps the real formatter in asynchronously once translations load — neither changes an entity state, sohasConfigOrEntityChangedmisses both.Compatibility
Two version gates, both in
src/entity-name.ts: 2026.4 forformatEntityName(it has existed since 2025.10 but with an incompatible signature — bare type strings then, structured items only in 2025.11–2026.3 — so feature detection isn't safe), and 2025.11 for the editor selector. Below 2026.4 behaviour is unchanged.Verification
npm run lintandnpm run rollupboth pass. The build is what caught the editor: widening the config type surfacedTS2322on the_namegetter, which is why the field was upgraded rather than left as a text input that would have shown an empty box for a structured name.dist/andpackage-lock.jsonare untouched by this branch.🤖 Generated with Claude Code