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

This commit is contained in:
Bram Kragten 2020-05-02 17:23:00 +02:00 committed by GitHub
parent 786da25b9f
commit bc68e20041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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