Use heat or cool slider mode for auto if there is only one mode (#17748)

This commit is contained in:
Paul Bottein 2023-08-31 13:00:58 +02:00 committed by GitHub
parent dfbaee1649
commit fa788a8223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -280,15 +280,21 @@ export class HaMoreInfoClimateTemperature extends LitElement {
);
}
const activeModes = this.stateObj.attributes.hvac_modes.filter(
(m) => m !== "off"
);
if (
supportsTargetTemperature &&
this._targetTemperature.value != null &&
this.stateObj.state !== UNAVAILABLE
) {
const heatCoolModes = this.stateObj.attributes.hvac_modes.filter((m) =>
["heat", "cool", "heat_cool"].includes(m)
);
const sliderMode =
SLIDER_MODES[
heatCoolModes.length === 1 && ["off", "auto"].includes(mode)
? heatCoolModes[0]
: mode
];
return html`
<div
class="container"
@ -299,9 +305,7 @@ export class HaMoreInfoClimateTemperature extends LitElement {
>
<ha-control-circular-slider
.inactive=${!active}
.mode=${mode === "off" && activeModes.length === 1
? SLIDER_MODES[activeModes[0]]
: SLIDER_MODES[mode]}
.mode=${sliderMode}
.value=${this._targetTemperature.value}
.min=${this._min}
.max=${this._max}