Skip to content

Commit

Permalink
Update todo list items when entity changes, only refresh on shopping …
Browse files Browse the repository at this point in the history
…lst updated event for shopping list platform
  • Loading branch information
bramkragten committed Oct 27, 2023
1 parent 9207f6c commit e824b23
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/panels/lovelace/cards/hui-todo-list-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
];
}

Expand All @@ -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() {
Expand Down

0 comments on commit e824b23

Please sign in to comment.