Skip to content

Commit

Permalink
fix: Do not fail when problem with stats encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdovhan committed Mar 15, 2024
1 parent f11f5cf commit 5eeddd1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/purifier-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,21 @@ export class PurifierCard extends LitElement {
} else if (attribute) {
state = get(this.entity.attributes, attribute);
} else if (entity_id) {
state = this.hass.states[entity_id].state;
state = this.hass.states[entity_id]?.state;
} else {
return nothing;
}

const value = html`
<ha-template
hass=${this.hass}
template=${value_template}
value=${state}
variables=${{ value: state }}
></ha-template>
`;
const value = state
? html`
<ha-template
hass=${this.hass}
template=${value_template}
value=${state}
variables=${{ value: state }}
></ha-template>
`
: nothing;

return html`
<div class="stats-block" @click="${() => this.handleMore(entity_id)}">
Expand Down

0 comments on commit 5eeddd1

Please sign in to comment.