Merge pull request #3949 from iantrich/fix-glance-state_image

picture-glance: check for entity state change
This commit is contained in:
Bram Kragten 2019-10-09 21:48:05 +02:00 committed by GitHub
commit 0d77bdaf32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@ import { longPress } from "../common/directives/long-press-directive";
import { processConfigEntities } from "../common/process-config-entities";
import { handleClick } from "../common/handle-click";
import { PictureGlanceCardConfig, ConfigEntity } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
const STATES_OFF = new Set(["closed", "locked", "not_home", "off"]);
@ -86,19 +87,16 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
}
protected shouldUpdate(changedProps: PropertyValues): boolean {
if (changedProps.has("_config")) {
if (hasConfigOrEntityChanged(this, changedProps)) {
return true;
}
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
if (!oldHass) {
return true;
}
if (this._entitiesDialog) {
for (const entity of this._entitiesDialog) {
if (
oldHass.states[entity.entity] !== this.hass!.states[entity.entity]
oldHass!.states[entity.entity] !== this.hass!.states[entity.entity]
) {
return true;
}
@ -108,7 +106,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
if (this._entitiesToggle) {
for (const entity of this._entitiesToggle) {
if (
oldHass.states[entity.entity] !== this.hass!.states[entity.entity]
oldHass!.states[entity.entity] !== this.hass!.states[entity.entity]
) {
return true;
}