Skip to content

Commit

Permalink
update hasChanged for formatEntityState, fix glance card shouldUpdate (
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts authored Sep 8, 2023
1 parent 4a6539d commit 7176a51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
24 changes: 2 additions & 22 deletions src/panels/lovelace/cards/hui-glance-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { createEntityNotFoundWarning } from "../components/hui-warning";
import "../components/hui-warning-element";
import { LovelaceCard, LovelaceCardEditor } from "../types";
import { GlanceCardConfig, GlanceConfigEntity } from "./types";
import { hasConfigOrEntitiesChanged } from "../common/has-changed";

@customElement("hui-glance-card")
export class HuiGlanceCard extends LitElement implements LovelaceCard {
Expand Down Expand Up @@ -121,28 +122,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
}

protected shouldUpdate(changedProps: PropertyValues): boolean {
if (changedProps.has("_config")) {
return true;
}

const oldHass = changedProps.get("hass") as HomeAssistant | undefined;

if (
!this._configEntities ||
!oldHass ||
oldHass.themes !== this.hass!.themes ||
oldHass.locale !== this.hass!.locale
) {
return true;
}

for (const entity of this._configEntities) {
if (oldHass.states[entity.entity] !== this.hass!.states[entity.entity]) {
return true;
}
}

return false;
return hasConfigOrEntitiesChanged(this, changedProps);
}

protected render() {
Expand Down
5 changes: 5 additions & 0 deletions src/panels/lovelace/common/has-changed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export function hasConfigChanged(
oldHass.themes !== element.hass!.themes ||
oldHass.locale !== element.hass!.locale ||
oldHass.localize !== element.hass.localize ||
oldHass.formatEntityState !== element.hass.formatEntityState ||
oldHass.formatEntityAttributeName !==
element.hass.formatEntityAttributeName ||
oldHass.formatEntityAttributeValue !==
element.hass.formatEntityAttributeValue ||
oldHass.config.state !== element.hass.config.state
) {
return true;
Expand Down

0 comments on commit 7176a51

Please sign in to comment.