From ec6666a4ea04ef9be83dd74d7ca5262202ef225d Mon Sep 17 00:00:00 2001 From: Tommy Goode Date: Thu, 17 Jul 2025 09:02:09 -0500 Subject: [PATCH] Add 'state' option for secondary entity info on Entities card (#26201) * add 'state' option for secondary entity info on Entities card * Use formatEntityState instead of computeStateDisplay --- src/panels/lovelace/cards/types.ts | 1 + src/panels/lovelace/components/hui-generic-entity-row.ts | 6 +++++- .../editor/config-elements/hui-generic-entity-row-editor.ts | 1 + src/translations/en.json | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 53f65f86e4..46433e3f05 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -73,6 +73,7 @@ export interface EntitiesCardEntityConfig extends EntityConfig { | "last-triggered" | "last-updated" | "position" + | "state" | "tilt-position" | "brightness"; action_name?: string; diff --git a/src/panels/lovelace/components/hui-generic-entity-row.ts b/src/panels/lovelace/components/hui-generic-entity-row.ts index 1e762dea67..ec9c22a1cc 100644 --- a/src/panels/lovelace/components/hui-generic-entity-row.ts +++ b/src/panels/lovelace/components/hui-generic-entity-row.ts @@ -146,7 +146,11 @@ export class HuiGenericEntityRow extends LitElement { 100 )} %` - : nothing)} + : this.config.secondary_info === "state" + ? html`${this.hass.formatEntityState( + stateObj + )}` + : nothing)} ` : nothing} diff --git a/src/panels/lovelace/editor/config-elements/hui-generic-entity-row-editor.ts b/src/panels/lovelace/editor/config-elements/hui-generic-entity-row-editor.ts index 70d8c9b6ae..2844690c79 100644 --- a/src/panels/lovelace/editor/config-elements/hui-generic-entity-row-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-generic-entity-row-editor.ts @@ -19,6 +19,7 @@ const SECONDARY_INFO_VALUES = { "last-updated": {}, "last-triggered": { domains: ["automation", "script"] }, position: { domains: ["cover"] }, + state: {}, "tilt-position": { domains: ["cover"] }, brightness: { domains: ["light"] }, }; diff --git a/src/translations/en.json b/src/translations/en.json index 23b39abc45..996d6c96d5 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -7305,7 +7305,8 @@ "position": "Position", "tilt-position": "Tilt position", "brightness": "Brightness", - "last-updated": "Last updated" + "last-updated": "Last updated", + "state": "State" }, "entity_row": { "divider": "Divider",