mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 13:27:22 +00:00
Update to show when entity is unavailable
This commit is contained in:
parent
5578580d78
commit
4c3db2119b
@ -82,10 +82,6 @@ export class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
|
||||
return html``;
|
||||
}
|
||||
const { title } = this.config;
|
||||
const states = this.hass.states;
|
||||
const entities = this.configEntities!.filter(
|
||||
(conf) => conf.entity in states
|
||||
);
|
||||
|
||||
applyThemesOnElement(this, this.hass!.themes, this.config.theme);
|
||||
|
||||
@ -94,7 +90,7 @@ export class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
|
||||
<ha-card .header="${title}">
|
||||
<div class="entities ${classMap({ "no-header": !title })}">
|
||||
${repeat<EntityConfig>(
|
||||
entities,
|
||||
this.configEntities!,
|
||||
(entityConf) => entityConf.entity,
|
||||
(entityConf) => this.renderEntity(entityConf)
|
||||
)}
|
||||
@ -137,6 +133,10 @@ export class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
|
||||
state-badge {
|
||||
margin: 8px 0;
|
||||
}
|
||||
.not-found {
|
||||
background-color: yellow;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
`;
|
||||
}
|
||||
@ -144,6 +144,12 @@ export class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
|
||||
private renderEntity(entityConf) {
|
||||
const stateObj = this.hass!.states[entityConf.entity];
|
||||
|
||||
if (!stateObj) {
|
||||
return html`<div class="entity not-found">Entity Not Available: ${
|
||||
entityConf.entity
|
||||
}</div>`;
|
||||
}
|
||||
|
||||
return html`
|
||||
<div
|
||||
class="entity"
|
||||
|
Loading…
x
Reference in New Issue
Block a user