Skip to content

Commit

Permalink
Handle disconnection and connection events to better support HA 0.112
Browse files Browse the repository at this point in the history
  • Loading branch information
gadgetchnnel committed Jun 28, 2020
1 parent e6f6837 commit fbe614e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lovelace-home-feed-card.js

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class HomeFeedCard extends LitElement {
this.moment.locale(this.browser_language);
}

connectedCallback() {
super.connectedCallback();
this._notificationMonitorInterval = setInterval(() => this.notificationMonitor(), 1000);
}

disconnectedCallback() {
if(this._notificationMonitorInterval) clearInterval(this._notificationMonitorInterval);
super.disconnectedCallback();
}

static get properties() { return {
_config: { type: Object },
hass: { type: Object }
Expand Down Expand Up @@ -226,7 +236,6 @@ class HomeFeedCard extends LitElement {
this.entities = this.processConfigEntities(this._config.entities);
this.calendars = this._config.calendars;
setTimeout(() => this.buildIfReady(), 10);
this.notificationMonitor();
}

processConfigEntities(entities) {
Expand Down Expand Up @@ -1050,11 +1059,6 @@ class HomeFeedCard extends LitElement {
this.refreshNotifications().then(() => {});
}
}

window.setTimeout(
() => this.notificationMonitor(),
1000
);
}

buildIfReady(){
Expand Down

0 comments on commit fbe614e

Please sign in to comment.