Don't disable thermostat when state is unknown (#5720)

This commit is contained in:
Bram Kragten 2020-05-02 17:23:00 +02:00
parent 61fdee14c6
commit 04a2ff7506

View File

@ -24,7 +24,7 @@ import {
compareClimateHvacModes, compareClimateHvacModes,
HvacMode, HvacMode,
} from "../../../data/climate"; } from "../../../data/climate";
import { UNAVAILABLE_STATES } from "../../../data/entity"; import { UNAVAILABLE } from "../../../data/entity";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { actionHandler } from "../common/directives/action-handler-directive"; import { actionHandler } from "../common/directives/action-handler-directive";
import { findEntities } from "../common/find-entites"; import { findEntities } from "../common/find-entites";
@ -125,20 +125,21 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
? stateObj.attributes.temperature ? stateObj.attributes.temperature
: stateObj.attributes.min_temp; : stateObj.attributes.min_temp;
const slider = UNAVAILABLE_STATES.includes(stateObj.state) const slider =
? html` <round-slider disabled="true"></round-slider> ` stateObj.state === UNAVAILABLE
: html` ? html` <round-slider disabled="true"></round-slider> `
<round-slider : html`
.value=${targetTemp} <round-slider
.low=${stateObj.attributes.target_temp_low} .value=${targetTemp}
.high=${stateObj.attributes.target_temp_high} .low=${stateObj.attributes.target_temp_low}
.min=${stateObj.attributes.min_temp} .high=${stateObj.attributes.target_temp_high}
.max=${stateObj.attributes.max_temp} .min=${stateObj.attributes.min_temp}
.step=${this._stepSize} .max=${stateObj.attributes.max_temp}
@value-changing=${this._dragEvent} .step=${this._stepSize}
@value-changed=${this._setTemperature} @value-changing=${this._dragEvent}
></round-slider> @value-changed=${this._setTemperature}
`; ></round-slider>
`;
const currentTemperature = !isNaN(stateObj.attributes.current_temperature) const currentTemperature = !isNaN(stateObj.attributes.current_temperature)
? svg` ? svg`
@ -322,7 +323,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
} }
private _getSetTemp(stateObj: HassEntity) { private _getSetTemp(stateObj: HassEntity) {
if (UNAVAILABLE_STATES.includes(stateObj.state)) { if (stateObj.state === UNAVAILABLE) {
return this.hass!.localize("state.default.unavailable"); return this.hass!.localize("state.default.unavailable");
} }