mirror of
https://github.com/GeorgeSG/lovelace-time-picker-card.git
synced 2026-11-03 11:48:45 +00:00
Keep an empty name meaning "use Home Assistant's name"
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 commit is contained in:
co-authored by
Claude Opus 5
parent
349c0aecf6
commit
7fc93eecea
@@ -174,7 +174,7 @@ name:
|
|||||||
- type: entity
|
- 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
|
`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
|
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.
|
visual editor offers both modes on Home Assistant 2025.11 and later.
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ export function computeEntityName(
|
|||||||
stateObj: HassEntity | undefined,
|
stateObj: HassEntity | undefined,
|
||||||
name: EntityName | undefined,
|
name: EntityName | undefined,
|
||||||
): string | 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;
|
const configuredName = typeof name === 'string' ? name : undefined;
|
||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ export interface TimePickerCardConfig extends LovelaceCardConfig {
|
|||||||
export type EntityName = string | EntityNameItem | EntityNameItem[];
|
export type EntityName = string | EntityNameItem | EntityNameItem[];
|
||||||
|
|
||||||
export type EntityNameItem =
|
export type EntityNameItem =
|
||||||
| { type: 'entity' | 'device' | 'parent_device' | 'area' | 'floor' }
|
| { type: 'entity' | 'device' | 'area' | 'floor' }
|
||||||
| { type: 'text'; text: string };
|
| { type: 'text'; text: string };
|
||||||
|
|
||||||
export type HourMode = 12 | 24 | undefined;
|
export type HourMode = 12 | 24 | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user