Update todo list items when entity changes, only refresh on shopping … (#18445)

This commit is contained in:
Bram Kragten 2023-10-27 15:47:37 +02:00 committed by GitHub
parent 9207f6c407
commit 4f09485b20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,10 +135,14 @@ export class HuiTodoListCard
public hassSubscribe(): Promise<UnsubscribeFunc>[] {
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() {