From 34d50f0c90f4a37b6000dad2ee11d6f50edaba4e Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Tue, 10 Sep 2019 00:14:12 -0500 Subject: [PATCH] Add image option to glance card entities (#3673) * Add image option to glance card entities Closes https://github.com/home-assistant/home-assistant-polymer/issues/3021 * properly order override --- src/components/entity/state-badge.ts | 8 ++++++-- src/panels/lovelace/cards/hui-glance-card.ts | 1 + src/panels/lovelace/cards/types.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/entity/state-badge.ts b/src/components/entity/state-badge.ts index 211331ae98..080587ddc5 100644 --- a/src/components/entity/state-badge.ts +++ b/src/components/entity/state-badge.ts @@ -21,6 +21,7 @@ class StateBadge extends LitElement { public hass?: HomeAssistant; @property() public stateObj?: HassEntity; @property() public overrideIcon?: string; + @property() public overrideImage?: string; @query("ha-icon") private _icon!: HaIcon; protected render(): TemplateResult | void { @@ -55,8 +56,11 @@ class StateBadge extends LitElement { }; if (stateObj) { // hide icon if we have entity picture - if (stateObj.attributes.entity_picture && !this.overrideIcon) { - let imageUrl = stateObj.attributes.entity_picture; + if ( + (stateObj.attributes.entity_picture && !this.overrideIcon) || + this.overrideImage + ) { + let imageUrl = this.overrideImage || stateObj.attributes.entity_picture; if (this.hass) { imageUrl = this.hass.hassUrl(imageUrl); } diff --git a/src/panels/lovelace/cards/hui-glance-card.ts b/src/panels/lovelace/cards/hui-glance-card.ts index be7ee5d4f6..f33d00674a 100644 --- a/src/panels/lovelace/cards/hui-glance-card.ts +++ b/src/panels/lovelace/cards/hui-glance-card.ts @@ -202,6 +202,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard { .hass=${this.hass} .stateObj=${stateObj} .overrideIcon=${entityConf.icon} + .overrideImage=${entityConf.image} > ` : ""} diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index ce1d21ad25..7c707f8af9 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -84,6 +84,7 @@ export interface ConfigEntity extends EntityConfig { export interface GlanceConfigEntity extends ConfigEntity { show_last_changed?: boolean; + image?: string; } export interface GlanceCardConfig extends LovelaceCardConfig {