mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix target range temperature in tile feature (#17772)
This commit is contained in:
parent
c291af5d97
commit
fb69deb617
@ -129,6 +129,33 @@ class HuiTargetTemperatureTileFeature
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _supportsTarget() {
|
||||||
|
const domain = computeStateDomain(this.stateObj!);
|
||||||
|
return (
|
||||||
|
(domain === "climate" &&
|
||||||
|
supportsFeature(
|
||||||
|
this.stateObj!,
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
|
)) ||
|
||||||
|
(domain === "water_heater" &&
|
||||||
|
supportsFeature(
|
||||||
|
this.stateObj!,
|
||||||
|
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _supportsTargetRange() {
|
||||||
|
const domain = computeStateDomain(this.stateObj!);
|
||||||
|
return (
|
||||||
|
domain === "climate" &&
|
||||||
|
supportsFeature(
|
||||||
|
this.stateObj!,
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (
|
if (
|
||||||
!this._config ||
|
!this._config ||
|
||||||
@ -147,94 +174,104 @@ class HuiTargetTemperatureTileFeature
|
|||||||
minimumFractionDigits: digits,
|
minimumFractionDigits: digits,
|
||||||
};
|
};
|
||||||
|
|
||||||
const domain = computeStateDomain(this.stateObj!);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(domain === "climate" &&
|
this._supportsTarget() &&
|
||||||
supportsFeature(
|
this._targetTemperature.value != null &&
|
||||||
this.stateObj,
|
this.stateObj.state !== UNAVAILABLE
|
||||||
ClimateEntityFeature.TARGET_TEMPERATURE
|
|
||||||
)) ||
|
|
||||||
(domain === "water_heater" &&
|
|
||||||
supportsFeature(
|
|
||||||
this.stateObj,
|
|
||||||
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
|
||||||
))
|
|
||||||
) {
|
) {
|
||||||
return html`
|
return html`
|
||||||
<ha-control-button-group>
|
<ha-control-button-group>
|
||||||
<ha-control-number-buttons
|
<ha-control-number-buttons
|
||||||
.formatOptions=${options}
|
.formatOptions=${options}
|
||||||
.target="value"
|
.target="value"
|
||||||
.value=${this.stateObj.attributes.temperature}
|
.value=${this.stateObj.attributes.temperature}
|
||||||
.min=${this._min}
|
.min=${this._min}
|
||||||
.max=${this._max}
|
.max=${this._max}
|
||||||
.step=${this._step}
|
.step=${this._step}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
.label=${this.hass.formatEntityAttributeName(
|
.label=${this.hass.formatEntityAttributeName(
|
||||||
this.stateObj,
|
this.stateObj,
|
||||||
"temperature"
|
"temperature"
|
||||||
)}
|
)}
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
"--control-number-buttons-focus-color": stateColor,
|
"--control-number-buttons-focus-color": stateColor,
|
||||||
})}
|
})}
|
||||||
.disabled=${this.stateObj!.state === UNAVAILABLE}
|
.disabled=${this.stateObj!.state === UNAVAILABLE}
|
||||||
>
|
>
|
||||||
</ha-control-number-buttons>
|
</ha-control-number-buttons>
|
||||||
</ha-control-number-buttons>
|
</ha-control-button-group>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
domain === "climate" &&
|
this._supportsTargetRange() &&
|
||||||
supportsFeature(
|
this._targetTemperature.low != null &&
|
||||||
this.stateObj,
|
this._targetTemperature.high != null &&
|
||||||
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
this.stateObj.state !== UNAVAILABLE
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return html`
|
return html`
|
||||||
<ha-control-button-group>
|
<ha-control-button-group>
|
||||||
<ha-control-number-buttons
|
<ha-control-number-buttons
|
||||||
.formatOptions=${options}
|
.formatOptions=${options}
|
||||||
.target=${"low"}
|
.target=${"low"}
|
||||||
.value=${(this.stateObj as ClimateEntity).attributes.target_temp_low}
|
.value=${this._targetTemperature.low}
|
||||||
.min=${this._min}
|
.min=${this._min}
|
||||||
.max=${Math.min(this._max, this._targetTemperature.high ?? this._max)}
|
.max=${Math.min(
|
||||||
.step=${this._step}
|
this._max,
|
||||||
@value-changed=${this._valueChanged}
|
this._targetTemperature.high ?? this._max
|
||||||
.label=${this.hass.formatEntityAttributeName(
|
)}
|
||||||
this.stateObj,
|
.step=${this._step}
|
||||||
"temperature"
|
@value-changed=${this._valueChanged}
|
||||||
)}
|
.label=${this.hass.formatEntityAttributeName(
|
||||||
style=${styleMap({
|
this.stateObj,
|
||||||
"--control-number-buttons-focus-color": stateColor,
|
"target_temp_low"
|
||||||
})}
|
)}
|
||||||
.disabled=${this.stateObj!.state === UNAVAILABLE}
|
style=${styleMap({
|
||||||
>
|
"--control-number-buttons-focus-color": stateColor,
|
||||||
</ha-control-number-buttons>
|
})}
|
||||||
<ha-control-number-buttons
|
.disabled=${this.stateObj!.state === UNAVAILABLE}
|
||||||
.formatOptions=${options}
|
>
|
||||||
.target=${"high"}
|
</ha-control-number-buttons>
|
||||||
.value=${(this.stateObj as ClimateEntity).attributes.target_temp_high}
|
<ha-control-number-buttons
|
||||||
.min=${Math.max(this._min, this._targetTemperature.low ?? this._min)}
|
.formatOptions=${options}
|
||||||
.max=${this._max}
|
.target=${"high"}
|
||||||
.step=${this._step}
|
.value=${this._targetTemperature.high}
|
||||||
@value-changed=${this._valueChanged}
|
.min=${Math.max(
|
||||||
.label=${this.hass.formatEntityAttributeName(
|
this._min,
|
||||||
this.stateObj,
|
this._targetTemperature.low ?? this._min
|
||||||
"temperature"
|
)}
|
||||||
)}
|
.max=${this._max}
|
||||||
style=${styleMap({
|
.step=${this._step}
|
||||||
"--control-number-buttons-focus-color": stateColor,
|
@value-changed=${this._valueChanged}
|
||||||
})}
|
.label=${this.hass.formatEntityAttributeName(
|
||||||
.disabled=${this.stateObj!.state === UNAVAILABLE}
|
this.stateObj,
|
||||||
>
|
"target_temp_high"
|
||||||
</ha-control-number-buttons>
|
)}
|
||||||
</ha-control-number-buttons>
|
style=${styleMap({
|
||||||
`;
|
"--control-number-buttons-focus-color": stateColor,
|
||||||
|
})}
|
||||||
|
.disabled=${this.stateObj!.state === UNAVAILABLE}
|
||||||
|
>
|
||||||
|
</ha-control-number-buttons>
|
||||||
|
</ha-control-button-group>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nothing;
|
return html`
|
||||||
|
<ha-control-button-group>
|
||||||
|
<ha-control-number-buttons
|
||||||
|
.disabled=${this.stateObj!.state === UNAVAILABLE}
|
||||||
|
.label=${this.hass.formatEntityAttributeName(
|
||||||
|
this.stateObj,
|
||||||
|
"temperature"
|
||||||
|
)}
|
||||||
|
style=${styleMap({
|
||||||
|
"--control-number-buttons-focus-color": stateColor,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
</ha-control-number-buttons>
|
||||||
|
</ha-control-button-group>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles() {
|
static get styles() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user