diff --git a/custom_card.json b/custom_card.json index 6338900..462d5c9 100644 --- a/custom_card.json +++ b/custom_card.json @@ -1,6 +1,6 @@ { "lovelace-home-feed-card": { - "version": "0.2.5", + "version": "0.2.6", "remote_location": "https://raw.githubusercontent.com/gadgetchnnel/lovelace-home-feed-card/master/lovelace-home-feed-card.js", "visit_repo": "https://github.com/gadgetchnnel/lovelace-home-feed-card", "changelog": "https://github.com/gadgetchnnel/lovelace-home-feed-card" diff --git a/lovelace-home-feed-card.js b/lovelace-home-feed-card.js index ef3df49..f38f841 100644 --- a/lovelace-home-feed-card.js +++ b/lovelace-home-feed-card.js @@ -212,6 +212,8 @@ class HomeFeedCard extends Polymer.Element { } async refreshNotifications() { + if(!this._hass) return; + var response = await this._hass.callWS({type: 'persistent_notification/get'}); if(this._config.id_filter) { response = response.filter(n => n.notification_id.match(this._config.id_filter)); @@ -488,14 +490,16 @@ class HomeFeedCard extends Polymer.Element { notificationMonitor() { let oldNotificationCount = this.notificationCount ? this.notificationCount : "0"; - - let notificationIndicator = this.notificationButton.shadowRoot.querySelector(".indicator div"); - let notificationCount = notificationIndicator ? notificationIndicator.innerText : "0"; - if(notificationCount != oldNotificationCount){ - this.notificationCount = notificationCount; - this.refreshNotifications().then(() => { - this.loadedNotifications = true; - }); + if(this.notificationButton) + { + let notificationIndicator = this.notificationButton.shadowRoot.querySelector(".indicator div"); + let notificationCount = notificationIndicator ? notificationIndicator.innerText : "0"; + if(notificationCount != oldNotificationCount){ + this.notificationCount = notificationCount; + this.refreshNotifications().then(() => { + this.loadedNotifications = true; + }); + } } window.setTimeout( () => this.notificationMonitor(),