Merge pull request #67 from bramkragten/entity-name-followup

Keep an empty name meaning Home Assistant's own name
This commit is contained in:
2026-09-30 11:18:19 +03:00
committed by GitHub
3 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ name:
- type: entity
```
Available part types are `entity`, `device`, `parent_device`, `area`, `floor`, and
Available part types are `entity`, `device`, `area`, `floor`, and
`text` (a literal, written as `{type: text, text: 'Alarm'}`). Parts that resolve to
nothing are dropped. A plain string `name` keeps working exactly as before, and the
visual editor offers both modes on Home Assistant 2025.11 and later.
+5
View File
@@ -43,6 +43,11 @@ export function computeEntityName(
stateObj: HassEntity | undefined,
name: EntityName | undefined,
): string | undefined {
// A configured empty name has always meant "use Home Assistant's name", but
// formatEntityName returns any string verbatim - including the empty one, which
// would blank the label. Normalise it to undefined so the formatter composes.
if (name === '') name = undefined;
const configuredName = typeof name === 'string' ? name : undefined;
if (!stateObj) {
+1 -2
View File
@@ -20,8 +20,7 @@ export interface TimePickerCardConfig extends LovelaceCardConfig {
export type EntityName = string | EntityNameItem | EntityNameItem[];
export type EntityNameItem =
| { type: 'entity' | 'device' | 'parent_device' | 'area' | 'floor' }
| { type: 'text'; text: string };
{ type: 'entity' | 'device' | 'area' | 'floor' } | { type: 'text'; text: string };
export type HourMode = 12 | 24 | undefined;