From c72bb5b22b8a6e47a7dcb5f2b1975a74fedc1f3d Mon Sep 17 00:00:00 2001 From: cdce8p <30130371+cdce8p@users.noreply.github.com> Date: Wed, 22 Apr 2020 10:50:52 +0200 Subject: [PATCH] Add secondary option for cover entities (#5556) * Add secondary option for cover entities * Replace string concatenation * Check for undefined --- src/panels/lovelace/cards/types.ts | 7 ++++++- .../lovelace/components/hui-generic-entity-row.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 8fb6bfeb7e..233cc65e3a 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -29,7 +29,12 @@ export interface EntityCardConfig extends LovelaceCardConfig { export interface EntitiesCardEntityConfig extends EntityConfig { type?: string; - secondary_info?: "entity-id" | "last-changed"; + secondary_info?: + | "entity-id" + | "last-changed" + | "last-triggered" + | "position" + | "tilt-position"; action_name?: string; service?: string; service_data?: object; diff --git a/src/panels/lovelace/components/hui-generic-entity-row.ts b/src/panels/lovelace/components/hui-generic-entity-row.ts index abc946bbce..fe154e0775 100644 --- a/src/panels/lovelace/components/hui-generic-entity-row.ts +++ b/src/panels/lovelace/components/hui-generic-entity-row.ts @@ -112,6 +112,16 @@ class HuiGenericEntityRow extends LitElement { : this.hass.localize( "ui.panel.lovelace.cards.entities.never_triggered" ) + : this.config.secondary_info === "position" && + stateObj.attributes.current_position !== undefined + ? `${this.hass.localize("ui.card.cover.position")}: ${ + stateObj.attributes.current_position + }` + : this.config.secondary_info === "tilt-position" && + stateObj.attributes.current_tilt_position !== undefined + ? `${this.hass.localize("ui.card.cover.tilt_position")}: ${ + stateObj.attributes.current_tilt_position + }` : "")} `