mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +00:00
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:
parent
9eae637814
commit
34d50f0c90
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
|
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user