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
This commit is contained in:
Ian Richardson 2019-09-10 00:14:12 -05:00 committed by Paulus Schoutsen
parent 9eae637814
commit 34d50f0c90
3 changed files with 8 additions and 2 deletions

View File

@ -21,6 +21,7 @@ class StateBadge extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
@property() public stateObj?: HassEntity; @property() public stateObj?: HassEntity;
@property() public overrideIcon?: string; @property() public overrideIcon?: string;
@property() public overrideImage?: string;
@query("ha-icon") private _icon!: HaIcon; @query("ha-icon") private _icon!: HaIcon;
protected render(): TemplateResult | void { protected render(): TemplateResult | void {
@ -55,8 +56,11 @@ class StateBadge extends LitElement {
}; };
if (stateObj) { if (stateObj) {
// hide icon if we have entity picture // hide icon if we have entity picture
if (stateObj.attributes.entity_picture && !this.overrideIcon) { if (
let imageUrl = stateObj.attributes.entity_picture; (stateObj.attributes.entity_picture && !this.overrideIcon) ||
this.overrideImage
) {
let imageUrl = this.overrideImage || stateObj.attributes.entity_picture;
if (this.hass) { if (this.hass) {
imageUrl = this.hass.hassUrl(imageUrl); imageUrl = this.hass.hassUrl(imageUrl);
} }

View File

@ -202,6 +202,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
.hass=${this.hass} .hass=${this.hass}
.stateObj=${stateObj} .stateObj=${stateObj}
.overrideIcon=${entityConf.icon} .overrideIcon=${entityConf.icon}
.overrideImage=${entityConf.image}
></state-badge> ></state-badge>
` `
: ""} : ""}

View File

@ -84,6 +84,7 @@ export interface ConfigEntity extends EntityConfig {
export interface GlanceConfigEntity extends ConfigEntity { export interface GlanceConfigEntity extends ConfigEntity {
show_last_changed?: boolean; show_last_changed?: boolean;
image?: string;
} }
export interface GlanceCardConfig extends LovelaceCardConfig { export interface GlanceCardConfig extends LovelaceCardConfig {