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}">
<div id="root">
<hui-image
.hass="${this._hass}"
.image="${this._config.image}"
.stateImage="${this._config.state_image}"
.cameraImage="${this._config.camera_image}"
.cameraView="${this._config.camera_view}"
.entity="${this._config.entity}"
.aspectRatio="${this._config.aspect_ratio}"
.hass=${this._hass}
.image=${this._config.image}
.stateImage=${this._config.state_image}
.stateFilter=${this._config.state_filter}
.cameraImage=${this._config.camera_image}
.cameraView=${this._config.camera_view}
.entity=${this._config.entity}
.aspectRatio=${this._config.aspect_ratio}
></hui-image>
${this._config.elements.map(
(elementConfig: LovelaceElementConfig) => {

View File

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

View File

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

View File

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