Fix number entity row availability when state unknown (#9475)

This commit is contained in:
Franck Nijhof 2021-06-29 14:57:39 +02:00 committed by GitHub
parent 0a83a704f1
commit 43503ba085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ import { customElement, property, state } from "lit/decorators";
import { computeStateDisplay } from "../../../common/entity/compute_state_display"; import { computeStateDisplay } from "../../../common/entity/compute_state_display";
import { computeRTLDirection } from "../../../common/util/compute_rtl"; import { computeRTLDirection } from "../../../common/util/compute_rtl";
import "../../../components/ha-slider"; import "../../../components/ha-slider";
import { UNAVAILABLE_STATES } from "../../../data/entity"; import { UNAVAILABLE } from "../../../data/entity";
import { setValue } from "../../../data/input_text"; import { setValue } from "../../../data/input_text";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { hasConfigOrEntityChanged } from "../common/has-changed"; import { hasConfigOrEntityChanged } from "../common/has-changed";
@ -75,7 +75,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
? html` ? html`
<div class="flex"> <div class="flex">
<ha-slider <ha-slider
.disabled=${UNAVAILABLE_STATES.includes(stateObj.state)} .disabled=${stateObj.state === UNAVAILABLE}
.dir=${computeRTLDirection(this.hass)} .dir=${computeRTLDirection(this.hass)}
.step="${Number(stateObj.attributes.step)}" .step="${Number(stateObj.attributes.step)}"
.min="${Number(stateObj.attributes.min)}" .min="${Number(stateObj.attributes.min)}"
@ -101,7 +101,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
<paper-input <paper-input
no-label-float no-label-float
auto-validate auto-validate
.disabled=${UNAVAILABLE_STATES.includes(stateObj.state)} .disabled=${stateObj.state === UNAVAILABLE}
pattern="[0-9]+([\\.][0-9]+)?" pattern="[0-9]+([\\.][0-9]+)?"
.step="${Number(stateObj.attributes.step)}" .step="${Number(stateObj.attributes.step)}"
.min="${Number(stateObj.attributes.min)}" .min="${Number(stateObj.attributes.min)}"