From 3ada2f3279c6c759f6bad20a57445d31adab34cf Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 8 Dec 2023 14:38:01 +0100 Subject: [PATCH] Fix label when there is no target (#18969) --- .../climate/ha-state-control-climate-humidity.ts | 6 ++++++ .../climate/ha-state-control-climate-temperature.ts | 11 +++++++---- .../ha-state-control-humidifier-humidity.ts | 4 +++- .../ha-state-control-water_heater-temperature.ts | 3 ++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/state-control/climate/ha-state-control-climate-humidity.ts b/src/state-control/climate/ha-state-control-climate-humidity.ts index be27b7bdb6..9918db1044 100644 --- a/src/state-control/climate/ha-state-control-climate-humidity.ts +++ b/src/state-control/climate/ha-state-control-climate-humidity.ts @@ -97,6 +97,12 @@ export class HaStateControlClimateHumidity extends LitElement { `; } + if (!this._targetHumidity) { + return html` +

${this.hass.formatEntityState(this.stateObj)}

+ `; + } + return html`

${this.hass.localize("ui.card.climate.humidity_target")} diff --git a/src/state-control/climate/ha-state-control-climate-temperature.ts b/src/state-control/climate/ha-state-control-climate-temperature.ts index 755b0ce6ab..0975b1bd99 100644 --- a/src/state-control/climate/ha-state-control-climate-temperature.ts +++ b/src/state-control/climate/ha-state-control-climate-temperature.ts @@ -164,14 +164,17 @@ export class HaStateControlClimateTemperature extends LitElement { } if ( - !supportsFeature( + (!supportsFeature( this.stateObj, ClimateEntityFeature.TARGET_TEMPERATURE - ) && - !supportsFeature( + ) || + this._targetTemperature.value === null) && + (!supportsFeature( this.stateObj, ClimateEntityFeature.TARGET_TEMPERATURE_RANGE - ) + ) || + this._targetTemperature.low === null || + this._targetTemperature.high === null) ) { return html`

${this.hass.formatEntityState(this.stateObj)}

diff --git a/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts b/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts index 9f9bf92605..648753ab66 100644 --- a/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts +++ b/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts @@ -110,7 +110,9 @@ export class HaStateControlHumidifierHumidity extends LitElement {

${action && action !== "off" && action !== "idle" ? actionLabel - : this.hass.localize("ui.card.humidifier.target")} + : this._targetHumidity + ? this.hass.localize("ui.card.humidifier.target") + : this.hass.formatEntityState(this.stateObj)}

`; } diff --git a/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts b/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts index bbcd5cdaad..4e52499618 100644 --- a/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts +++ b/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts @@ -107,7 +107,8 @@ export class HaStateControlWaterHeaterTemperature extends LitElement { !supportsFeature( this.stateObj, WaterHeaterEntityFeature.TARGET_TEMPERATURE - ) + ) || + !this._targetTemperature ) { return html`

${this.hass.formatEntityState(this.stateObj)}