mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 14:07:55 +00:00
Handle unknown states
This commit is contained in:
parent
e9ffdeff19
commit
4033131f2e
@ -18,7 +18,7 @@ import { computeStateName } from "../../../common/entity/compute_state_name";
|
|||||||
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import { HumidifierEntity } from "../../../data/humidifier";
|
import { HumidifierEntity } from "../../../data/humidifier";
|
||||||
import { UNAVAILABLE } from "../../../data/entity";
|
import { UNAVAILABLE_STATES } from "../../../data/entity";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { findEntities } from "../common/find-entites";
|
import { findEntities } from "../common/find-entites";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
@ -96,8 +96,7 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const rtlDirection = computeRTLDirection(this.hass);
|
const rtlDirection = computeRTLDirection(this.hass);
|
||||||
|
|
||||||
const slider =
|
const slider = UNAVAILABLE_STATES.includes(stateObj.state)
|
||||||
stateObj.state === UNAVAILABLE
|
|
||||||
? html` <round-slider disabled="true"></round-slider> `
|
? html` <round-slider disabled="true"></round-slider> `
|
||||||
: html`
|
: html`
|
||||||
<round-slider
|
<round-slider
|
||||||
@ -122,17 +121,17 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
|||||||
class="set-value"
|
class="set-value"
|
||||||
>
|
>
|
||||||
${
|
${
|
||||||
stateObj.state === UNAVAILABLE
|
UNAVAILABLE_STATES.includes(stateObj.state) ||
|
||||||
? this.hass.localize("state.default.unavailable")
|
this._setHum === undefined ||
|
||||||
: this._setHum === undefined || this._setHum === null
|
this._setHum === null
|
||||||
? ""
|
? ""
|
||||||
: svg`
|
: svg`
|
||||||
${this._setHum.toFixed()}
|
${this._setHum.toFixed()}
|
||||||
`
|
|
||||||
}
|
|
||||||
<tspan dx="-3" dy="-6.5" style="font-size: 4px;">
|
<tspan dx="-3" dy="-6.5" style="font-size: 4px;">
|
||||||
%
|
%
|
||||||
</tspan>
|
</tspan>
|
||||||
|
`
|
||||||
|
}
|
||||||
</text>
|
</text>
|
||||||
</svg>
|
</svg>
|
||||||
<svg id="set-values">
|
<svg id="set-values">
|
||||||
@ -144,7 +143,8 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
|||||||
>
|
>
|
||||||
${this.hass!.localize(`state.default.${stateObj.state}`)}
|
${this.hass!.localize(`state.default.${stateObj.state}`)}
|
||||||
${
|
${
|
||||||
stateObj.attributes.mode
|
stateObj.attributes.mode &&
|
||||||
|
!UNAVAILABLE_STATES.includes(stateObj.state)
|
||||||
? html`
|
? html`
|
||||||
-
|
-
|
||||||
${this.hass!.localize(
|
${this.hass!.localize(
|
||||||
@ -249,7 +249,7 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _getSetHum(stateObj: HassEntity): undefined | number {
|
private _getSetHum(stateObj: HassEntity): undefined | number {
|
||||||
if (stateObj.state === UNAVAILABLE) {
|
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user