From 4f09485b20047945e4f16bd9dd68b66eeb54fd56 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 27 Oct 2023 15:47:37 +0200 Subject: [PATCH] =?UTF-8?q?Update=20todo=20list=20items=20when=20entity=20?= =?UTF-8?q?changes,=20only=20refresh=20on=20shopping=20=E2=80=A6=20(#18445?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lovelace/cards/hui-todo-list-card.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/cards/hui-todo-list-card.ts b/src/panels/lovelace/cards/hui-todo-list-card.ts index f2d38bc64f83..68af5f2b5914 100644 --- a/src/panels/lovelace/cards/hui-todo-list-card.ts +++ b/src/panels/lovelace/cards/hui-todo-list-card.ts @@ -135,10 +135,14 @@ export class HuiTodoListCard public hassSubscribe(): Promise[] { return [ - this.hass!.connection.subscribeEvents( - () => this._fetchData(), - "shopping_list_updated" - ), + this.hass!.connection.subscribeEvents(() => { + if ( + this._entityId && + this.hass!.entities[this._entityId]?.platform === "shopping_list" + ) { + this._fetchData(); + } + }, "shopping_list_updated"), ]; } @@ -159,6 +163,15 @@ export class HuiTodoListCard ) { applyThemesOnElement(this, this.hass.themes, this._config.theme); } + + if ( + this._entityId && + oldHass && + oldHass.states[this._entityId] !== this.hass.states[this._entityId] && + this.hass.entities[this._entityId]?.platform !== "shopping_list" + ) { + this._fetchData(); + } } protected render() {