Handle unknown state (#4481)

This commit is contained in:
Bram Kragten 2020-01-15 18:01:59 +01:00 committed by Paulus Schoutsen
parent bc731a9dc3
commit aaefe0b09f
2 changed files with 4 additions and 3 deletions

View File

@ -145,7 +145,7 @@ export class HaDevicesDataTable extends LitElement {
return html`
${name}<br />
${device.area} | ${device.integration}<br />
${battery
${battery && !isNaN(battery.state as any)
? html`
${battery.state}%
<ha-state-icon
@ -205,7 +205,7 @@ export class HaDevicesDataTable extends LitElement {
const battery = batteryEntity
? this.hass.states[batteryEntity]
: undefined;
return battery
return battery && !isNaN(battery.state as any)
? html`
${battery.state}%
<ha-state-icon

View File

@ -62,7 +62,8 @@ class HuiSensorEntityRow extends LitElement implements EntityRow {
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<div>
${stateObj.attributes.device_class === "timestamp" &&
stateObj.state !== "unavailable"
stateObj.state !== "unavailable" &&
stateObj.state !== "unknown"
? html`
<hui-timestamp-display
.hass="${this.hass}"