add state_filter to picture cards (#3791)

This commit is contained in:
Ian Richardson 2019-09-30 02:49:11 -05:00 committed by Bram Kragten
parent 2dd5cd586b
commit c69585db98
4 changed files with 36 additions and 30 deletions

View File

@ -58,13 +58,14 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard {
<ha-card .header="${this._config.title}"> <ha-card .header="${this._config.title}">
<div id="root"> <div id="root">
<hui-image <hui-image
.hass="${this._hass}" .hass=${this._hass}
.image="${this._config.image}" .image=${this._config.image}
.stateImage="${this._config.state_image}" .stateImage=${this._config.state_image}
.cameraImage="${this._config.camera_image}" .stateFilter=${this._config.state_filter}
.cameraView="${this._config.camera_view}" .cameraImage=${this._config.camera_image}
.entity="${this._config.entity}" .cameraView=${this._config.camera_view}
.aspectRatio="${this._config.aspect_ratio}" .entity=${this._config.entity}
.aspectRatio=${this._config.aspect_ratio}
></hui-image> ></hui-image>
${this._config.elements.map( ${this._config.elements.map(
(elementConfig: LovelaceElementConfig) => { (elementConfig: LovelaceElementConfig) => {

View File

@ -114,21 +114,22 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard {
return html` return html`
<ha-card> <ha-card>
<hui-image <hui-image
.hass="${this.hass}" .hass=${this.hass}
.image="${this._config.image}" .image=${this._config.image}
.stateImage="${this._config.state_image}" .stateImage=${this._config.state_image}
.cameraImage="${computeDomain(this._config.entity) === "camera" .stateFilter=${this._config.state_filter}
.cameraImage=${computeDomain(this._config.entity) === "camera"
? this._config.entity ? this._config.entity
: this._config.camera_image}" : this._config.camera_image}
.cameraView="${this._config.camera_view}" .cameraView=${this._config.camera_view}
.entity="${this._config.entity}" .entity=${this._config.entity}
.aspectRatio="${this._config.aspect_ratio}" .aspectRatio=${this._config.aspect_ratio}
@ha-click="${this._handleTap}" @ha-click=${this._handleTap}
@ha-hold="${this._handleHold}" @ha-hold=${this._handleHold}
.longPress="${longPress()}" .longPress=${longPress()}
class="${classMap({ class=${classMap({
clickable: stateObj.state !== UNAVAILABLE, clickable: stateObj.state !== UNAVAILABLE,
})}" })}
></hui-image> ></hui-image>
${footer} ${footer}
</ha-card> </ha-card>

View File

@ -136,16 +136,17 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
this._config.camera_image this._config.camera_image
), ),
})}" })}"
@ha-click="${this._handleTap}" @ha-click=${this._handleTap}
@ha-hold="${this._handleHold}" @ha-hold=${this._handleHold}
.longPress="${longPress()}" .longPress=${longPress()}
.hass="${this.hass}" .hass=${this.hass}
.image="${this._config.image}" .image=${this._config.image}
.stateImage="${this._config.state_image}" .stateImage=${this._config.state_image}
.cameraImage="${this._config.camera_image}" .stateFilter=${this._config.state_filter}
.cameraView="${this._config.camera_view}" .cameraImage=${this._config.camera_image}
.entity="${this._config.entity}" .cameraView=${this._config.camera_view}
.aspectRatio="${this._config.aspect_ratio}" .entity=${this._config.entity}
.aspectRatio=${this._config.aspect_ratio}
></hui-image> ></hui-image>
<div class="box"> <div class="box">
${this._config.title ${this._config.title

View File

@ -144,6 +144,7 @@ export interface PictureElementsCardConfig extends LovelaceCardConfig {
camera_image?: string; camera_image?: string;
camera_view?: HuiImage["cameraView"]; camera_view?: HuiImage["cameraView"];
state_image?: {}; state_image?: {};
state_filter: string[];
aspect_ratio?: string; aspect_ratio?: string;
entity?: string; entity?: string;
elements: LovelaceElementConfig[]; elements: LovelaceElementConfig[];
@ -156,6 +157,7 @@ export interface PictureEntityCardConfig extends LovelaceCardConfig {
camera_image?: string; camera_image?: string;
camera_view?: HuiImage["cameraView"]; camera_view?: HuiImage["cameraView"];
state_image?: {}; state_image?: {};
state_filter: string[];
aspect_ratio?: string; aspect_ratio?: string;
tap_action?: ActionConfig; tap_action?: ActionConfig;
hold_action?: ActionConfig; hold_action?: ActionConfig;
@ -170,6 +172,7 @@ export interface PictureGlanceCardConfig extends LovelaceCardConfig {
camera_image?: string; camera_image?: string;
camera_view?: HuiImage["cameraView"]; camera_view?: HuiImage["cameraView"];
state_image?: {}; state_image?: {};
state_filter: string[];
aspect_ratio?: string; aspect_ratio?: string;
entity?: string; entity?: string;
tap_action?: ActionConfig; tap_action?: ActionConfig;