diff --git a/custom_card.json b/custom_card.json index c58c7b0..9f4ab1e 100644 --- a/custom_card.json +++ b/custom_card.json @@ -1,6 +1,6 @@ { "lovelace-home-feed-card": { - "version": "0.3.5b2", + "version": "0.3.5b3", "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 f9ac59c..73ad9a6 100644 --- a/lovelace-home-feed-card.js +++ b/lovelace-home-feed-card.js @@ -404,6 +404,15 @@ class HomeFeedCard extends HomeFeedCardHelpers.LitElement { getEntities() { let data = this.entities.filter(i => i.multiple_items !== true && i.include_history !== true).map(i => { let stateObj = this._hass.states[i.entity]; + + if(stateObj == null) { + return { entity_id: i.entity, icon: null, entity: i.entity, display_name: this._hass.localize( + "ui.panel.lovelace.warning.entity_not_found", + "entity", + i.entity + ), more_info_on_tap: false, + content_template: null, state: "unavailable", stateObj: null, item_type: "unavailable", }; + } let domain = i.entity.split(".")[0]; if(!i.exclude_states.includes(stateObj.state) && (domain != "automation" || stateObj.attributes.last_triggered) // Exclude automations which have never been triggered @@ -930,6 +939,11 @@ class HomeFeedCard extends HomeFeedCardHelpers.LitElement { case "multi_entity": var icon = n.icon; + var contentText = `${n.display_name}`; + break; + case "unavailable": + var icon = "mdi:alert-circle"; + var contentText = `${n.display_name}`; break; default: @@ -1048,14 +1062,24 @@ class HomeFeedCard extends HomeFeedCardHelpers.LitElement { ${closeLink}
- - ${timeItem} + ${this.itemContent(n, compact_mode, contentText)} + ${n.item_type != "unavailable" ? timeItem : null}
${compact_mode ? HomeFeedCardHelpers.html`` : HomeFeedCardHelpers.html`
`} `; } + itemContent(item, compact_mode, contentText){ + if(item.item_type == "unavailable"){ + return HomeFeedCardHelpers.html` + ${contentText} + `; + } + return HomeFeedCardHelpers.html` + + `; + } get notificationButton() { if(!this._notificationButton){ this._notificationButton = this.rootElement.querySelector("hui-notifications-button");